def get_parent()

in project/paperbench/paperbench/rubric/tasks.py [0:0]


    def get_parent(self, node_id: str) -> "TaskNode":
        """Finds the parent of the node with `node_id`."""

        if self.id == node_id:
            raise ValueError("The root node has no parent.")

        for sub_task in self.sub_tasks:
            if sub_task.id == node_id:
                return self
            try:
                return sub_task.get_parent(node_id)
            except ValueError:
                continue

        raise ValueError(f"Node with id '{node_id}' not found. Can't find its parent.")