def get(self) -> SelectedSubtree:
    """Returns the result of a singleton selection.

    Returns:
      The selected subtree from this selection.

    Raises:
      ValueError: If this selection does not have exactly one selected subtree.
    """
    if len(self.selected_by_path) != 1:
      raise ValueError(
          "Selection.get() can only be called on selections with one selected"
          f" element, but there were {len(self.selected_by_path)}. Consider"
          " using .selected_by_path instead."
      )

    (value,) = self.selected_by_path.values()
    return value
Returns the result of a singleton selection.

    Returns:
      The selected subtree from this selection.

    Raises:
      ValueError: If this selection does not have exactly one selected subtree.
    
penzai/core/selectors.py