check if tree is balanced