Balancing the tree