def METHOD_NAME(target, path, build_root):
  """Looks for a file with a specific name closest to a project path.
  This is similar to the logic used by a version-control system (like git) to
  find its configuration directory (.git) based on the current directory when a
  command is invoked.
  Args:
    target: The file name to search for.
    path: The directory where the search starts. The search will explore the
        given directory's ascendants using the parent relationship. Should be an
        absolute path.
    build_root: A directory that acts as a fence for the search. If the search
        reaches this directory, it will not advance to its parent. Should be an
        absolute path.
  Returns:
    The path to a file with the desired name. None if the search failed.
  """
  candidate = os.path.join(path, target)
  if os.path.isfile(candidate):
    return candidate
  if path == build_root:
    return None
  parent = os.path.dirname(path)
  if parent == path:
    return None
  return METHOD_NAME(target, parent, build_root)