import typing
import pathlib
import glob


def _get_paths(patterns: typing.Set[pathlib.Path]) -> typing.Set[pathlib.Path]:
    """Convert a set of file/directory patterns into a list of matching files."""
    raw = [
        pathlib.Path(item)
        for pattern in patterns
        for item in glob.iglob(str(pattern), recursive=True)
    ]
    files = [p for p in raw if not p.is_dir()]
    output = files + [
        child
        for p in raw
        for item in glob.iglob(f"{p}/**/*", recursive=True)
        if p.is_dir() and not (child := pathlib.Path(item)).is_dir()
    ]
    return set(output)