Adding a function to check if a tree is balanced or not