def METHOD_NAME(
    paths: Iterable[Path],
    exclude: Optional[Pattern],
    extend_exclude: Optional[Pattern],
    gitignore: Optional[PathSpec],
) -> Iterator[Path]:
    for path in paths:
        if not should_parse_path(path, exclude, extend_exclude, gitignore):
            continue
        if path.is_dir():
            yield from METHOD_NAME(
                path.iterdir(),
                exclude,
                extend_exclude,
                gitignore + get_gitignore(path) if gitignore is not None else None,
            )
        elif path.is_file():
            yield path