docs: def change_parent(sender, instance, **kwargs):
      """
      When the given task instance has changed. Look at task and context and change
      the corresponding item relation.
      """
      if instance.id is None:
          return
      if len({'task', 'task_id'} & set(instance.changed_fields)) != 0:
          diff = instance.diff
          parent = diff['task'][0] if 'task' in diff else diff['task_id'][0]
          parent_id = parent.item_id if isinstance(parent, Task) else Task.objects.get(pk=parent).item_id
          child_id = instance.item_id
          ItemRelation.objects.filter(parent_id=parent_id, child_id=child_id).delete()
          ItemRelation.objects.create(parent_id=instance.task.item_id, child_id=child_id, visible=True)
      if len({'context', 'context_id'} & set(instance.changed_fields)) != 0:
          diff = instance.diff
          parent = diff['context'][0] if 'context' in diff else diff['context_id'][0]
          parent_id = parent.item_id if isinstance(parent, Context) else Context.objects.get(pk=parent).item_id
          child_id = instance.item_id
          ItemRelation.objects.filter(parent_id=parent_id, child_id=child_id).delete()
          ItemRelation.objects.create(parent_id=instance.context.item_id, child_id=child_id, visible=False)