moved hierarchical tree construction to the htree file