Code to check if a tree is balanced or not.