def METHOD_NAME(
    user: UserID, ruleslist: FilteredPushRules
) -> Dict[str, Dict[str, List[Dict[str, Any]]]]:
    """Converts a list of rawrules and a enabled map into nested dictionaries
    to match the Matrix client-server format for push rules"""
    rules: Dict[str, Dict[str, List[Dict[str, Any]]]] = {"global": {}}
    rules["global"] = _add_empty_priority_class_arrays(rules["global"])
    for r, enabled in ruleslist.rules():
        template_name = _priority_class_to_template_name(r.priority_class)
        rulearray = rules["global"][template_name]
        template_rule = _rule_to_template(r)
        if not template_rule:
            continue
        rulearray.append(template_rule)
        _convert_type_to_value(template_rule, user)
        template_rule["enabled"] = enabled
        if "conditions" not in template_rule:
            # Not all formatted rules have explicit conditions, e.g. "room"
            # rules omit them as they can be derived from the kind and rule ID.
            #
            # If the formatted rule has no conditions then we can skip the
            # formatting of conditions.
            continue
        # Remove internal stuff.
        template_rule["conditions"] = copy.deepcopy(template_rule["conditions"])
        for c in template_rule["conditions"]:
            c.pop("_cache_key", None)
            _convert_type_to_value(c, user)
    return rules