code: def clear_obj(self, obj):
          Remove all nodes with `obj` and their descendants."""
          obj_nodes = self.get_nodes_with(obj)
          removed = set()
          for node in obj_nodes:
              if self.has_node(node):
                  removed.update(self.clear_descendants(node))
          return removed
docs: Remove all nodes with `obj` and their descendants.