cubicweb-forge #1220817 verify internal logic of `SetTicketLoadLeft` hook [deprecated]

I can't understand the code flow, especially the else statement and the possible mix-up between self.entity and edited:

class SetTicketLoadLeft(Hook):
  """automatically set load_left according to load if unspecified"""
  __regid__ = 'set_ticket_load'
  events = ('before_add_entity', 'before_update_entity')
  __select__ = Hook.__select__ & is_instance('Ticket',)

  def __call__(self):
      edited = self.entity.edited_attributes
      has_load_left = 'load_left' in edited
      if 'load' in edited and self.entity.load_left is None:
          self.entity.load_left = self.entity['load']
      elif not has_load_left and 'load_left' in edited:
          # cleanup, this may cause undesired changes
          del self.entity['load_left']
done in<not specified>
load left0.000
closed by<not specified>