def METHOD_NAME(path: str) -> Optional[str]:
    """
    Traverse the parent directories of the given path and find the closest
    compile_commands.json. If no JSON file exists with this name up to the root
    then None returns.
    The path of the first compilation database is returned even if it doesn't
    contain a corresponding entry for the given source file in "path".
    """
    path = os.path.abspath(path)
    root = os.path.abspath(os.sep)
    while True:
        path = os.path.dirname(path)
        compile_commands_json = os.path.join(path, COMPILATION_DATABASE)
        if os.path.isfile(compile_commands_json):
            return compile_commands_json
        if path == root:
            break