code: def _remove_references(self, removed_part):
          
          removed_part.parent = None
  
          # Remove labels in the hierarchy pointing to this part.
          referrers_to_remove = set()
          for referrer in removed_part.referrers:
              if removed_part not in referrer.ancestors():
                  for label, referred_part in list(referrer.labels.items()):
                      if referred_part is removed_part:
                          del referrer.labels[label]
                          referrers_to_remove.add(referrer)
          removed_part.referrers -= referrers_to_remove
  
          # Remove labels in this part pointing into the hierarchy.
          labels_to_delete = []
          if isinstance(removed_part, Compound):
              for label, part in list(removed_part.labels.items()):
                  if not isinstance(part, Compound):
                      for p in part:
                          self._remove_references(p)
                  elif removed_part not in part.ancestors():
                      try:
                          part.referrers.discard(removed_part)
                      except KeyError:
                          pass
                      else:
                          labels_to_delete.append(label)
          for label in labels_to_delete:
              removed_part.labels.pop(label, None)
docs: Remove labels pointing to this part and vice versa.