Converting a BinaryExpression to a Literal node

Hello,
I have a BinaryExpression and I would like to convert it to a Literal, as I am making a format and expressions like these do not work.
This is my BinaryExpression:
(original code: 9 + 10 + 11 + 12 + 13)

{
    "type": "BinaryExpression",
    "start": 48,
    "end": 69,
    "left": {
        "type": "BinaryExpression",
        "start": 48,
        "end": 64,
        "left": {
            "type": "BinaryExpression",
            "start": 48,
            "end": 59,
            "left": {
                "type": "BinaryExpression",
                "start": 48,
                "end": 54,
                "left": {
                    "type": "Literal",
                    "start": 48,
                    "end": 49,
                    "value": 9,
                    "raw": "9"
                },
                "operator": "+",
                "right": {
                    "type": "Literal",
                    "start": 52,
                    "end": 54,
                    "value": 10,
                    "raw": "10"
                }
            },
            "operator": "+",
            "right": {
                "type": "Literal",
                "start": 57,
                "end": 59,
                "value": 11,
                "raw": "11"
            }
        },
        "operator": "+",
        "right": {
            "type": "Literal",
            "start": 62,
            "end": 64,
            "value": 12,
            "raw": "12"
        }
    },
    "operator": "+",
    "right": {
        "type": "Literal",
        "start": 67,
        "end": 69,
        "value": 13,
        "raw": "13"
    }
}

and I would like to convert it to:

{
    "type": "Literal",
    "start": 48,
    "end": 69,
    "value": 55,
    "raw": "55"
}

Is there a way to do this? I tried thinking of ways to do this but none worked. Please leave suggestions on how to do this.

Thanks :slight_smile: