Let's consider I have the following *plain* object:

```
var numberedList = {
    "1": "Text of 1",
    "1.1": ["array of 1.1"],
    "1.2": {
        key: "object of 1.2"
    },
    "1.1.1": 999,
    "1.2.1": true,
    "1.2.2": function () {
        return "function of 1.2.2";
    },
    "1.3": null,
    "2": 2
}

```

I want to accomplish the following multidimensional array:

*To easy explain myself:*

```
[
    ["1",
        [
            [
                [
                    "1.1",
                    [
                        "1.1.1"
                    ]
                ]
            ],
            [
                [
                    "1.2",
                    [
                        "1.2.1",
                        "1.2.2"
                    ]
                ],
            ],
            "1.3"
        ]
    ],
    "2"
]

```

Final array:

```
[
    [
        "Text of 1",
        [
            [
                [
                    ["array of 1.1"],
                    [
                        999
                    ]
                ]
            ],
            [
                [
                    {
                        key: "object of 1.2"
                    },
                    [
                        true,
                        function()
                        {
                            return "function of 1.2.2";
                        }
                    ]
                ],
            ],
            null
        ]
    ],
    2
]

```

Note that the deepest elements are not wrapped into an array.

How can I do a **generic recursion function** to accomplish this in pure **vanilla js?**

The main objective is to perform a tree of `console.group()` calls such as the `console.groupEnd()`would be also called on the end of each tree branch. It would be a bonus to help me to accomplish this also – given the object on the top execute these console calls.