code: 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
docs: Calculate tree balance factor