With the following data format:
const flat = {
    '100': 'L1',
    '100.200': 'L1, J2',
    '100.200.300': 'L1, J2, A3',
    '100.200.400': 'L1, J2, A4',
    '100.300': 'L1, J3',
    '100.400.500': 'L1, J4, A5'
};
I want to change it to something like this:
{
    "100":{
        "name":"L1",
        "children":{
            "200":{
                "name":"L1, J2",
                "children":{
                    "300":{
                        "name":"L1, J2, A3"
                    },
                    "400":{
                        "name":"L1, J2, A4"
                    }
                }
            },
            "300":{
                "name":"L1, J3"
            },
            "400":{
                "name":null,
                "children":{
                    "500":{
                        "name":"L1, J4, A5"
                    }
                }
            }
        }
    }
}
I've been trying to implement some things from this Stack Overflow post although they only cover a lot of my use cases and it's quite hard to figure out.
 
     
    