def compress_for_rename(paths):
case_map = dict((os.path.normcase(p), p) for p in paths)<EOL>remaining = set(case_map)<EOL>unchecked = sorted(set(os.path.split(p)[<NUM_LIT:0>]<EOL>for p in case_map.values()), key=len)<EOL>wildcards = set()<EOL>def norm_join(*a):<EOL><INDENT>return os.path.normcase(os.path.join(*a))<EOL><DEDENT>for root in unchecked:<EOL><INDENT>if any(os.path.normcase(root).startswith(w)<EOL>for w in wildcards):<EOL><INDENT>continue<EOL><DEDENT>all_files = set()<EOL>all_subdirs = set()<EOL>for dirname, subdirs, files in os.walk(root):<EOL><INDENT>all_subdirs.update(norm_join(root, dirname, d)<EOL>for d in subdirs)<EOL>all_files.update(norm_join(root, dirname, f)<EOL>for f in files)<EOL><DEDENT>if not (all_files - remaining):<EOL><INDENT>remaining.difference_update(all_files)<EOL>wildcards.add(root + os.sep)<EOL><DEDENT><DEDENT>return set(map(case_map.__getitem__, remaining)) | wildcards<EOL>
Returns a set containing the paths that need to be renamed.

    This set may include directories when the original sequence of paths
    included every file on disk.