hierarchical tree traversal