def cleanup_candidates(root, prefix, keep):
max_existing = _max(map(parse_num, find_suffixes(root, prefix)), default=-<NUM_LIT:1>)<EOL>max_delete = max_existing - keep<EOL>paths = find_prefixed(root, prefix)<EOL>paths, paths2 = itertools.tee(paths)<EOL>numbers = map(parse_num, extract_suffixes(paths2, prefix))<EOL>for path, number in zip(paths, numbers):<EOL><INDENT>if number <= max_delete:<EOL><INDENT>yield path<EOL><DEDENT><DEDENT>
lists candidates for numbered directories to be removed - follows py.path