Add function for subtree rebalancing