I have this "lookup" dictionary, which represents nodes:
# Original "lookup" dictionary
{
0 : [1, 2],
2 : [3],
4 : [5]
}
...and I wish to create a new dictionary based on this, like so:
# New multidimensional dictionary
{
0 : {
1 : {},
2 : {
3 : {}
}
}
4 : {
5 : {}
}
}
}
How can this be achieved using recursion?
The original "lookup" dictionary's keys represent parent nodes and the values represent children nodes in one or more node trees.
The original "lookup" dictionary contains an unknown amount of keys/values and the depth is unknown.