def METHOD_NAME(rule: PushRule) -> Optional[Dict[str, Any]]:
    templaterule: Dict[str, Any]
    unscoped_rule_id = _rule_id_from_namespaced(rule.rule_id)
    template_name = _priority_class_to_template_name(rule.priority_class)
    if template_name in ["override", "underride"]:
        templaterule = {"conditions": rule.conditions, "actions": rule.actions}
    elif template_name in ["sender", "room"]:
        templaterule = {"actions": rule.actions}
        unscoped_rule_id = rule.conditions[0]["pattern"]
    elif template_name == "content":
        if len(rule.conditions) != 1:
            return None
        thecond = rule.conditions[0]
        templaterule = {"actions": rule.actions}
        if "pattern" in thecond:
            templaterule["pattern"] = thecond["pattern"]
        elif "pattern_type" in thecond:
            templaterule["pattern_type"] = thecond["pattern_type"]
        else:
            return None
    else:
        # This should not be reached unless this function is not kept in sync
        # with PRIORITY_CLASS_INVERSE_MAP.
        raise ValueError("Unexpected template_name: %s" % (template_name,))
    templaterule["rule_id"] = unscoped_rule_id
    templaterule["default"] = rule.default
    return templaterule