How to Check if a Tree is Balanced with Python