finding whether a tree is balanced