def _get_stmt_by_group(self, stmt_type, stmts_this_type, eh):
        stmt_by_first = collections.defaultdict(lambda: [])
        stmt_by_second = collections.defaultdict(lambda: [])
        none_first = collections.defaultdict(lambda: [])
        none_second = collections.defaultdict(lambda: [])
        stmt_by_group = collections.defaultdict(lambda: [])
        for stmt_tuple in stmts_this_type:
            _, stmt = stmt_tuple
            entities = self._get_entities(stmt, stmt_type, eh)
            if stmt_type == Complex:
                assert None not in entities
                assert len(entities) > 0
                entities.sort()
                key = tuple(entities)
                if stmt_tuple not in stmt_by_group[key]:
                    stmt_by_group[key].append(stmt_tuple)
            elif stmt_type == Conversion:
                assert len(entities) > 0
                key = (entities[0],
                       tuple(sorted(entities[1:len(stmt.obj_from)+1])),
                       tuple(sorted(entities[-len(stmt.obj_to):])))
                if stmt_tuple not in stmt_by_group[key]:
                    stmt_by_group[key].append(stmt_tuple)
            elif len(entities) == 1:
                assert None not in entities
                key = tuple(entities)
                if stmt_tuple not in stmt_by_group[key]:
                    stmt_by_group[key].append(stmt_tuple)
            else:
                key = tuple(entities)
                assert len(key) == 2
                assert key != (None, None)
                if key[0] is None and stmt_tuple not in none_first[key[1]]:
                    none_first[key[1]].append(stmt_tuple)
                elif key[1] is None and stmt_tuple not in none_second[key[0]]:
                    none_second[key[0]].append(stmt_tuple)
                elif None not in key:
                    if stmt_tuple not in stmt_by_group[key]:
                        stmt_by_group[key].append(stmt_tuple)
                    if key not in stmt_by_first[key[0]]:
                        stmt_by_first[key[0]].append(key)
                    if key not in stmt_by_second[key[1]]:
                        stmt_by_second[key[1]].append(key)
        if none_first:
            for second_arg, stmts in none_first.items():
                second_arg_keys = stmt_by_second[second_arg]
                if not second_arg_keys:
                    stmt_by_group[(None, second_arg)] = stmts
                for second_arg_key in second_arg_keys:
                    stmt_by_group[second_arg_key] += stmts
        if none_second:
            for first_arg, stmts in none_second.items():
                first_arg_keys = stmt_by_first[first_arg]
                if not first_arg_keys:
                    stmt_by_group[(first_arg, None)] = stmts
                for first_arg_key in first_arg_keys:
                    stmt_by_group[first_arg_key] += stmts
        return stmt_by_group