Flattening of js multi-level nested objects

there is such an object

var wrap_group = [
    {
        value: "A",
        group: [
            {
                value: "1",
                group: [
                    {value: "12"}
                ]
            },
            {
                value: "3",
                group: [
                    {value: "10"}
                ]
            }
        ]
    },
    {
        value: "B",
        group: [
        {
            value: "2",
            group: [
                {value: "22"}
            ]
        }
        ]
    }
]

want to gracefully convert the object to the following form:
wrap_group = [

{
    building_number: "A",
    floor_number: "1",
    room_number: "12"
},
{
    building_number: "A",
    floor_number: "3",
    room_number: "10"
},
{
    building_number: "B",
    floor_number: "2",
    room_number: "22"
},

]
Please introduce the specific ideas and codes.

Mar.24,2021

can be transformed into a depth-first search traversal print path problem.

simple implementation:

function flatSub(arr, value)
{
    return  [].concat(...arr.map(function(item) {
        return {building_number: value,floor_number:item.value, room_number: item.group[0].value}
    }))
}

var result = [].concat(...wrap_group.map(function(item) {
    return flatSub(item.group, item.value)
}))

console.log(result)
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b40140-2c4d9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b40140-2c4d9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?