balanced tree implementation AND get the height of tree