def update_balances(self, recursive=True):
if self.node:<EOL><INDENT>if recursive:<EOL><INDENT>if self.node.left:<EOL><INDENT>self.node.left.update_balances()<EOL><DEDENT>if self.node.right:<EOL><INDENT>self.node.right.update_balances()<EOL><DEDENT><DEDENT>self.balance = self.node.left.height - self.node.right.height<EOL><DEDENT>else:<EOL><INDENT>self.balance = <NUM_LIT:0><EOL><DEDENT>
Calculate tree balance factor