human
Complete this python program:
def find_highest_files(directory, unversioned, regex):
assistant
#Here is the Python program you requested.

    """Find the highest numbered file (kernel or initrd numbering scheme)
    in a given directory that matches a given pattern.  Used for
    auto-booting the latest kernel in a directory.
    """
    files = find_matching_files(directory, regex)
    get_numbers = re.compile('(\\d+).(\\d+).(\\d+)')
    def max2(a, b):
        'Returns    the    larger    of    the    two    values'
        av = get_numbers.search(os.path.basename(a)).groups()
        bv = get_numbers.search(os.path.basename(b)).groups()
        ret = (cmp(av[0], bv[0]) or cmp(av[1], bv[1]) or cmp(av[2], bv[2]))
        if (ret < 0):
            return b
        return a
    if (len(files) > 0):
        return reduce(max2, files)
    last_chance = os.path.join(directory, unversioned)
    if os.path.exists(last_chance):
        return last_chance
    return None