from pathlib import Path


def _get_project_for_path(path: Path):
    """
    Get the NCI project used to store the given path, if any.
    >>> _get_project_for_path(Path('/g/data/v10/some/data/path.txt'))
    'v10'
    >>> _get_project_for_path(Path('/g/data4/fk4/some/data/path.txt'))
    'fk4'
    >>> _get_project_for_path(Path('/scratch/da82/path.txt'))
    'da82'
    >>> _get_project_for_path(Path('/tmp/other/data'))
    """
    posix_path = path.as_posix()
    if posix_path.startswith("/g/data"):
        return posix_path.split("/")[3]
    if posix_path.startswith("/scratch/"):
        return posix_path.split("/")[2]
    return None