import pathlib


def _get_path(directory: pathlib.Path, base_name: str) -> pathlib.Path:
    """Finds the existing path with one of the allowed extensions."""
    options = ("yaml", "json", "toml", "txt")
    return next(
        d for ext in options if (d := directory.joinpath(f"{base_name}.{ext}")).exists()
    )