<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def remove_orphans(self, instance, **kwargs):
 """ When an item is deleted, first delete any Activity object that has been created on its behalf. """

      from activity_monitor.models import Activity
      try:
        instance_content_type = ContentType.objects.get_for_model(instance)
        timeline_item = Activity.objects.get(content_type=instance_content_type, object_id=instance.pk)
        timeline_item.delete()
      except Activity.DoesNotExist:
        return