hier_to_tree function

Convert a nested hierarchy into the default format