I'm rewriting an old project. For arcane reasons (legacy corporation database, can't change), tree-shaped data is stored in the database in a peculiar way: each node has two properties defined: node depth, and a list of bottom-most depth child nodes.
How would I handle transforming that to a regular tree? I'm currently at the level where I have a set of all nodes to be placed in the tree, but I'm at a loss now. One thing I thought of is adding the nodes from the deepest level and going up to the root node, but that's a lot of messing with dangling nodes and resizing the tree.
EDIT: Just realised that my method would involve checking every combination of lower-level nodes to find one whose children sum equals to that of the higher-level one. Nope.