if self.balance_factor > 1:
# right is heavier
if self.right_child.balance < 0:
# right_child.left is heavier, RL case
self._rl_case()
elif self.right_child.balance > 0:
# right_child.right is heavier, RR case
self._rr_case()
elif self.balance_factor < -1:
# left is heavier
if self.left_child.balance < 0:
# left_child.left is heavier, LL case
self._ll_case()
elif self.left_child.balance > 0:
# left_child.right is heavier, LR case
self._lr_case()
Should be changed to
if self.balance_factor > 1:
# right is heavier
if self.right_child.balance_factor < 0:
# right_child.left is heavier, RL case
self._rl_case()
elif self.right_child.balance_factor > 0:
# right_child.right is heavier, RR case
self._rr_case()
elif self.balance_factor < -1:
# left is heavier
if self.left_child.balance_factor < 0:
# left_child.left is heavier, LL case
self._ll_case()
elif self.left_child.balance_factor > 0:
# left_child.right is heavier, LR case
self._lr_case()
Because there is no such property "balance", but only "balance_factor"
It looks like a typo in lob.py (436:447).
Should be changed to
Because there is no such property "balance", but only "balance_factor"