def create_next_candidates(prev_candidates, length):
<EOL>item_set = set()<EOL>for candidate in prev_candidates:<EOL><INDENT>for item in candidate:<EOL><INDENT>item_set.add(item)<EOL><DEDENT><DEDENT>items = sorted(item_set)<EOL>tmp_next_candidates = (frozenset(x) for x in combinations(items, length))<EOL>if length < <NUM_LIT:3>:<EOL><INDENT>return list(tmp_next_candidates)<EOL><DEDENT>next_candidates = [<EOL>candidate for candidate in tmp_next_candidates<EOL>if all(<EOL>True if frozenset(x) in prev_candidates else False<EOL>for x in combinations(candidate, length - <NUM_LIT:1>))<EOL>]<EOL>return next_candidates<EOL>
Returns the apriori candidates as a list.

Arguments:
    prev_candidates -- Previous candidates as a list.
    length -- The lengths of the next candidates.