It\'s been a while from those school years. Got a job as IT specialist at a hospital. Trying to move to do some actual programming now. I\'m working on binary trees now, a
Balancing usually depends on the length of the longest path on each direction. The above algorithm is not going to do that for you.
What are you trying to implement? There are self-balancing trees around (AVL/Red-black). In fact, Java trees are balanced.