<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def expand_folder(files):
 """Return a clone of file list files where all directories are recursively replaced with their contents."""

    expfiles = []
    for file in files:
        if os.path.isdir(file):
            for dirpath, dirnames, filenames in os.walk(file):
                for filename in filenames:
                    expfiles.append(os.path.join(dirpath, filename))
        else:
            expfiles.append(file)

    for path in expfiles:
        if not os.path.exists(path):
            sys.stderr.write('%s: No such file or directory\n' % path)

    return expfiles