http://www.perlmonks.org?node_id=538407


in reply to how to construct tree from parent pointer list

or yet another alternative: Tree::Simple