def transform_rules(rules):
    """Transforms a list of rules into a list of tuples with
    a frozenset for each field, to detect if a rule supersedes another.
    """
    transformed_rules = []
    for device_group, ruletype, rule_entry in rules:
        # Disabled rules can be ignored
        if rule_entry.find("./disabled") is not None and rule_entry.find("./disabled").text == "yes":
            continue

        rule_name = rule_entry.get('name')
        rule_values = {}
        rule_values['src_zones'] = frozenset([elem.text for elem in rule_entry.findall('./from/member')])
        rule_values['src_members'] = frozenset([elem.text for elem in rule_entry.findall('./source/member')])
        rule_values['users'] = frozenset([elem.text for elem in rule_entry.findall('./source-user/')])
        rule_values['dest_zones'] = frozenset([elem.text for elem in rule_entry.findall('./to/member')])
        rule_values['dest_members'] = frozenset([elem.text for elem in rule_entry.findall('./destination/member')])
        rule_values['application'] = frozenset([elem.text for elem in rule_entry.findall('./application/')])
        rule_values['service'] = frozenset([elem.text for elem in rule_entry.findall('./service/')])
        rule_values['url_category'] = frozenset([elem.text for elem in rule_entry.findall('./category/')])
        rule_values['action'] = frozenset([elem.text for elem in rule_entry.findall('./action')])
        transformed_rules.append((device_group, ruletype, rule_name, rule_entry, rule_values))
    return transformed_rules