(self, recursive=True)
Calculate tree balance factor
Calculate tree balance factor
Calculate tree balance factor
def update_balances(self, recursive=True):
        """
        Calculate tree balance factor

        """
        if self.node:
            if recursive:
                if self.node.left:
                    self.node.left.update_balances()
                if self.node.right:
                    self.node.right.update_balances()

            self.balance = self.node.left.height - self.node.right.height
        else:
            self.balance = 0
def update_balances ( self , recursive = True ) : if self . node : if recursive : if self . node . left : self . node . left . update_balances ( ) if self . node . right : self . node . right . update_balances ( ) self . balance = self . node . left . height - self . node . right . height else : self . balance = 0