def flip_tree(node):
 if hasattr(node, 'root'):
  node = node.get_root()
 if node.left:
  flip_tree(node.left)
 if node.right:
  flip_tree(node.right)
 (node.left, node.right) = (node.right, node.left)

def flip_tree ( node ) : if hasattr ( node , 'root' ) : node = node . get_root ( ) if node . left : flip_tree ( node . left ) if node . right : flip_tree ( node . right ) ( node . left , node . right ) = ( node . right , node . left )
flips the tree by pivoting the children from bottom to top .