<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def prune_to_ingroup(self):
 """Remove nodes and edges from tree if they are not the ingroup or a descendant of it."""

        # Prune to just the ingroup
        if not self._ingroup_node_id:
            _LOG.debug('No ingroup node was specified.')
            self._ingroup_node_id = self.root_node_id
        elif self._ingroup_node_id != self.root_node_id:
            self._do_prune_to_ingroup()
            self.root_node_id = self._ingroup_node_id
        else:
            _LOG.debug('Ingroup node is root.')
        return self.root_node_id