def collectReviewTeams(reviewers):
    """collectReviewTeams(reviewers) -> dictionary

Takes a dictionary as returned by getReviewersAndWatchers() or
getPendingReviewers() and transform into a dictionary mapping sets of users to
sets of files that those groups of users share review responsibilities for.  The
same user may appear in number of sets, as may the same file.

If None appears as a key in the returned dictionary, the set of files it is
mapped to have changes in them with no assigned reviewers."""

    teams = {}

    for file_id, file_reviewers in reviewers.items():
        if None in file_reviewers:
            teams.setdefault(None, set()).add(file_id)
        team = frozenset(filter(None, file_reviewers.keys()))
        if team: teams.setdefault(team, set()).add(file_id)

    return teams