def group_features_group_filter(groups, person, feature):
    """This returns a list of groups filtered such that the given person has
    a role listed in the given feature for each group."""
    feature_groups = set([])
    for g in groups:
        for r in person.role_set.filter(group=g):
            if r.name.slug in getattr(r.group.type.features, feature):
                feature_groups.add(g)
    return list(feature_groups)