<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def find_config(directory_or_file, debug=False):
 """Return configuration filename. If `directory_or_file` is a file, return the real-path of that file. If it is a directory, find the configuration (any file name in CONFIG_FILES) in that directory or its ancestors. """

    directory_or_file = os.path.realpath(directory_or_file)
    if os.path.isfile(directory_or_file):
        if debug:
            print('using config file {}'.format(directory_or_file),
                  file=sys.stderr)
        return directory_or_file
    directory = directory_or_file

    while directory:
        for filename in CONFIG_FILES:
            candidate = os.path.join(directory, filename)
            if os.path.exists(candidate):
                if debug:
                    print('using config file {}'.format(candidate),
                          file=sys.stderr)
                return candidate

        parent_directory = os.path.dirname(directory)
        if parent_directory == directory:
            break
        else:
            directory = parent_directory