def METHOD_NAME(path: str, dirname: str | None = None) -> bool:
    """Check the list of referenced files to see if `path` has been flagged.
    Walks up the directory tree in case there is a recursive flag on one of the parent
    directories.
    """
    if dirname is None:
        dirname = os.path.dirname(path)
    refs = referenced.get(dirname, set())
    if isinstance(refs, bool):
        return refs
    if path in refs:
        return True
    parentdir = os.path.dirname(dirname)
    if parentdir:
        return METHOD_NAME(path, parentdir)
    return False