'Execute all rules from this rules list. All when condition with same priority will be performed before
calling then actions.
:param matches:
:type matches:
:param context:
:type context:
:return:
:rtype:'

def execute_all_rules(self, matches, context):

    ret = []
    for (priority, priority_rules) in groupby(sorted(self), (lambda rule: rule.priority)):
        sorted_rules = toposort_rules(list(priority_rules))
        for rules_group in sorted_rules:
            rules_group = list(sorted(rules_group, key=self.index))
            group_log_level = None
            for rule in rules_group:
                if ((group_log_level is None) or (group_log_level < rule.log_level)):
                    group_log_level = rule.log_level
            log(group_log_level, '%s    independent    rule(s)    at    priority    %s.', len(rules_group), priority)
            for rule in rules_group:
                when_response = execute_rule(rule, matches, context)
                if (when_response is not None):
                    ret.append((rule, when_response))
    return ret
