check whether a tree is balanced or not