traverse_hierarchy function

Traverse the network hierarchy