def _find_build_dir(default_build_dir: Path=Path('out')) -> Optional[Path]:
    'Searches for a build directory, returning the first it finds.'
    if default_build_dir.joinpath('build.ninja').exists():
        return default_build_dir
    for path in default_build_dir.glob('**/build.ninja'):
        return path.parent
    for path in Path.cwd().glob('**/build.ninja'):
        return path.parent
    return None
Searches for a build directory, returning the first it finds.
def _find_build_dir(default_build_dir: Path=Path('out')) -> Optional[Path]:
    
    if default_build_dir.joinpath('build.ninja').exists():
        return default_build_dir
    for path in default_build_dir.glob('**/build.ninja'):
        return path.parent
    for path in Path.cwd().glob('**/build.ninja'):
        return path.parent
    return None