def path(self) -> str:
        """Return the file-like path from the root to this node."""
        if self.is_root:
            return "/"
        else:
            root, *ancestors = tuple(reversed(self.parents))
            # don't include name of root because (a) root might not have a name & (b) we want path relative to root.
            names = [*(node.name for node in ancestors), self.name]
            return "/" + "/".join(names)
Return the file-like path from the root to this node.
xarray/core/treenode.py