Here is a quick idea:
Search the list once and find the root (the one that never appears in child column) and its child (let's call them Q and R, respectively).
These 2 have levels 1 and 2, respectively.
Then search the list again to find the child of R, (let it be S) which will have level 3.
Then search the list again to find the child of S, (let it be T) which will have level 4.
Etc.
Repeat until all items have a level assigned.
I think the above could also work for multiple items being in the same level or multiple children from a same parent.
Once you have assigned levels to all items, it will be easy to output them in hierarchical form.