def METHOD_NAME(
    subvol: Subvol, subtree: Path
) -> Generator[ProvidesPath, None, None]:
    'Yields "Provides" instances for a path `subtree` in `subvol`.'
    # "Provides" classes use image-absolute paths that are `str` (for now).
    # Accept any string type to ease future migrations.
    # pyre-fixme[9]: subtree has type `Path`; used as `bytes`.
    subtree = b"/" + subtree
    protected_paths = protected_path_set(subvol)
    for prot_path in protected_paths:
        rel_to_subtree = (b"/" / prot_path).relpath(subtree)
        if not rel_to_subtree.has_leading_dot_dot():
            yield ProvidesDoNotAccess(path=rel_to_subtree)
    subtree_full_path = subvol.path(subtree)
    subtree_exists = False
    filetype_to_relpaths = defaultdict(list)
    # Traverse the subvolume as root, so that we have permission to access
    # everything.
    for type_and_path in subvol.run_as_root(
        [
            # -P is the analog of --no-dereference in GNU tools
            #
            # Filter out the protected paths at traversal time.  If one of the
            # paths has a very large or very slow mount, traversing it would
            # have a devastating effect on build times, so let's avoid looking
            # inside protected paths entirely.  An alternative would be to
            # `send` and to parse the sendstream, but this is ok too.
            "find",
            "-P",
            subtree_full_path,
            "(",
            *itertools.dropwhile(
                lambda x: x == "-o",  # Drop the initial `-o`
                itertools.chain.from_iterable(
                    [
                        # `normpath` removes the trailing / for protected dirs
                        "-o",
                        "-path",
                        subvol.path(p.normpath()),
                    ]
                    for p in protected_paths
                ),
            ),
            ")",
            "-prune",
            "-o",
            "-printf",
            "%y %p\\0",
        ],
        stdout=subprocess.PIPE,
    ).stdout.split(b"\0"):
        if not type_and_path:  # after the trailing \0
            continue
        filetype_bytes, abspath = type_and_path.split(b" ", 1)
        relpath = Path(abspath).relpath(subtree_full_path)
        assert not relpath.has_leading_dot_dot(), (
            abspath,
            subtree_full_path,
        )
        # We already "provided" this path above, and it should have been
        # filtered out by `find`.
        assert not is_path_protected(relpath, protected_paths), relpath
        if relpath == b".":
            subtree_exists = True
        filetype = filetype_bytes.decode()
        filetype_to_relpaths[filetype].append(relpath)
    for filetype, relpaths in filetype_to_relpaths.items():
        if filetype in ["b", "c", "p", "f", "s"]:
            yield from [ProvidesFile(path=r) for r in relpaths]
        elif filetype == "d":
            yield from [ProvidesDirectory(path=r) for r in relpaths]
        elif filetype == "l":
            symlink_paths = [str(subtree_full_path / r) for r in relpaths]
            # xargs --null means each input line needs to be delimited by \0
            # readlink --zero means each output line ends with \0 instead of \n
            readlink_vals = subvol.run_as_root(
                ["xargs", "--null", "readlink", "--zero"],
                stdout=subprocess.PIPE,
                input="\0".join(symlink_paths),
                text=True,
            ).stdout.split("\0")[:-1]
            assert len(relpaths) == len(readlink_vals), (
                relpaths,
                readlink_vals,
            )
            yield from [
                ProvidesSymlink(path=relpath, target=Path(readlink_val))
                for relpath, readlink_val in zip(relpaths, readlink_vals)
            ]
        else:  # pragma: no cover
            # pyre-fixme[61]: `abspath` may not be initialized here.
            raise AssertionError(f"Unknown {filetype} for {abspath}")
    # We should've gotten a CalledProcessError from `find`.
    assert subtree_exists, f"{subtree} does not exist in {subvol.path()}"