def _get_item(self: Tree, path: str | NodePath) -> Tree | T_DataArray:
        """
        Returns the object lying at the given path.

        Raises a KeyError if there is no object at the given path.
        """
        if isinstance(path, str):
            path = NodePath(path)

        if path.root:
            current_node = self.root
            root, *parts = list(path.parts)
        else:
            current_node = self
            parts = list(path.parts)

        for part in parts:
            if part == "..":
                if current_node.parent is None:
                    raise KeyError(f"Could not find node at {path}")
                else:
                    current_node = current_node.parent
            elif part in ("", "."):
                pass
            elif current_node.get(part) is None:
                raise KeyError(f"Could not find node at {path}")
            else:
                current_node = current_node.get(part)
        return current_node

        Returns the object lying at the given path.

        Raises a KeyError if there is no object at the given path.
        
xarray/core/treenode.py