from typing import Optional
from pathlib import Path


def _find_in_cwd_or_parents(name: str) -> Optional[Path]:
    """Finds a file with the given name starting in the cwd and working up to root."""
    for parent in (Path().absolute() / name).parents:
        path = parent / name
        if path.is_file():
            return path
    return None