def group_compatible_matches(matches):
    """ Groups matches into compatible sets of indices of non-conflicting matches.
        Indices are given by the positions in the matches list.
        :param matches A list of Matches.

        :return A list of sets of integers. Each set is unique and contains matches indices
                of compatible Matches.
    """
    are_all_clashes = True
    clash_pairs = []
    for i in range(len(matches)):
        for j in range(i + 1, len(matches)):
            if i != j:
                if matches[i].is_compatible(matches[j]):
                    are_all_clashes = False
                else:
                    clash_pairs.append((i, j))
                    clash_pairs.append((j, i))
    combinations = [{i} for i in range(len(matches))]
    if are_all_clashes:
        return combinations
    for i in range(len(matches)):
        for comb in combinations:
            if i not in comb:
                if comb.union({i}) in combinations:
                    combinations.remove(comb)
                    break
                clash = False
                for match_id in comb:
                    if (i, match_id) in clash_pairs:
                        clash = True
                        break
                if not clash:
                    comb.add(i)
    return combinations
