implemented tree_balance()