def deselect(self) -> Any:
    """Rebuilds the tree, forgetting which nodes were selected.

    Returns:
      A copy of `remainder` with the holes filled by the values in
      `selected_by_path`. If called on an ordinary selection, this rebuilds
      the original tree.
    """

    def rebuild(subtree) -> Any:
      """Processes nodes in the remainder to rebuild the tree."""
      if isinstance(subtree, SelectionHole):
        # Pull out the value for each hole.
        return self.selected_by_path[subtree.path]
      elif isinstance(subtree, SelectionQuote):
        # Unquote one level of quoting.
        return subtree.quoted
      else:
        # An ordinary PyTree leaf in the remainder; leave it as is.
        return subtree

    with _wrap_selection_errors(self):
      return jax.tree_util.tree_map(
          rebuild, self.remainder, is_leaf=_is_hole_or_quote
      )
Rebuilds the tree, forgetting which nodes were selected.

    Returns:
      A copy of `remainder` with the holes filled by the values in
      `selected_by_path`. If called on an ordinary selection, this rebuilds
      the original tree.
    
penzai/core/selectors.py