I am stuck with a challenge to re-arange a flat unbalanced hierarchy that is build bottom up, i.e. mapping a child element to parent and the parent's parent and so on, to a top down structure, i.e. starting from root and populating the structure downwards. Because the tree is unbalanced some end with a lower hierarchy level than others.
Example:
Source:
Child|Parent+0|Parent+1|Parent+2|Parent+3|Parent+4
Julia|Peter|Alice|Paul|Sara|Bianca
Chris|Jen|Bob|Fred|Bianca|NaN
Ben|John|Bianca|NaN|NaN
Target:
Parent-0|Parent-1|Parent-2|Parent-3|Parent-4|Child
Bianca|Sara|Paul|Alice|Peter|Julia
Bianca|Fred|Bob|Jen|NaN|Chris
Bianca|John|NaN|NaN|NaN|Ben
I've tried different ideas but so far had no luck. Appreciate your help or ideas.