Solved TreeHeight in java