def find_config_files(
        cls, target_path: Path, filenames: Sequence[str], search_parent: bool = True
    ) -> Iterator["PoeConfigFile"]:
        """
        Generate a PoeConfigFile for all potential config files starting from the
        target_path in order of precedence.

        If search_parent is False then check if the target_path points to a config file
        or a directory containing a config file.

        If search_parent is True then also search for the config file in parent
        directories in ascending order.

        If the given target_path is a file, then it may be named as any toml, json, or
        yaml file, otherwise the config file name must match one of `filenames`.
        """

        def scan_dir(target_dir: Path):
            for filename in filenames:
                if target_dir.joinpath(filename).exists():
                    yield cls(target_dir.joinpath(filename))

        target_path = target_path.resolve()

        if target_path.is_dir():
            yield from scan_dir(target_path)

            if search_parent:
                parent_path = target_path
                while len(parent_path.parents) > 1:
                    parent_path = parent_path.parent
                    yield from scan_dir(parent_path)

        elif target_path.exists() and target_path.name.endswith(
            (".toml", ".json", ".yaml")
        ):
            yield cls(target_path)

        Generate a PoeConfigFile for all potential config files starting from the
        target_path in order of precedence.

        If search_parent is False then check if the target_path points to a config file
        or a directory containing a config file.

        If search_parent is True then also search for the config file in parent
        directories in ascending order.

        If the given target_path is a file, then it may be named as any toml, json, or
        yaml file, otherwise the config file name must match one of `filenames`.
        
poethepoet/config/file.py