<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def walk_file(filename, walk_after, recurse=None, archive_mtime=None):
 """Optimize an individual file."""

    filename = os.path.normpath(filename)

    result_set = set()

    if _is_skippable(filename):
        return result_set

    walk_after = timestamp.get_walk_after(filename, walk_after)

    # File is a directory
    if os.path.isdir(filename):
        return walk_dir(filename, walk_after, recurse, archive_mtime)

    if _is_older_than_timestamp(filename, walk_after, archive_mtime):
        return result_set

    # Check image format
    try:
        image_format = detect_format.detect_file(filename)
    except Exception:
        res = Settings.pool.apply_async(stats.ReportStats,
                                        (filename,),
                                        {'error': "Detect Format"})
        result_set.add(res)
        image_format = False

    if not image_format:
        return result_set

    if Settings.list_only:
        # list only
        print("{}: {}".format(filename, image_format))
        return result_set

    if detect_format.is_format_selected(image_format, comic.FORMATS,
                                        comic.PROGRAMS):
        # comic archive
        result = walk_comic_archive(filename, image_format, walk_after)
    else:
        # regular image
        args = [filename, image_format, Settings]
        result = Settings.pool.apply_async(optimize.optimize_image,
                                           args=(args,))
    result_set.add(result)
    return result_set