check if a binary tree is balanced-- modified with less code