def METHOD_NAME(self, action, header):
    def _add_keymatch_rule():
        """ Select rule or listitem key to match """
        _dialogkeys = [i for i in ACTION_RULES]
        x = Dialog().select(get_localized(32444), _dialogkeys)
        if x == -1:
            return -1
        action.setdefault(_dialogkeys[x], ACTION_RULES[_dialogkeys[x]].get('default', ' '))
        return _dialogkeys[x]
    def _edit_keymatch_value(key, value):
        """ Select TMDbHelper value to match against """
        _dialogbuiltins = {
            'edit': lambda: Dialog().input(header, defaultt=value),
            'delete': lambda: None}
        _actionoption = ACTION_RULES[key].get('options')
        if _actionoption:  # If there's pre-set options then the rule cannot be edited
            _dialogbuiltins.pop('edit')
        _dialogvalues = [i for i in _dialogbuiltins]
        _dialogvalues += _actionoption or ACTION_VALUES
        x = Dialog().select(get_localized(32443).format(key), _dialogvalues)
        if x == -1:  # If user cancelled we return the old value
            return value
        new_value = _dialogvalues[x]
        return _dialogbuiltins[new_value]() if new_value in _dialogbuiltins else new_value
    _keys = [k for k in action.keys()]
    _dialogitems = [f'{k}: {action[k]}' for k in _keys]
    _dialogitems += [get_localized(32442), get_localized(192), get_localized(190)]
    x = Dialog().select(header, _dialogitems)
    preset = None
    if x == -1:  # User cancelled by pressing back
        return -1
    if _dialogitems[x] == get_localized(32442):  # Add new action
        key = _add_keymatch_rule()
        preset = action.get(key)
    elif _dialogitems[x] == get_localized(192):  # Clear actions
        key = -1
        action = {}
    elif _dialogitems[x] == get_localized(190):  # Save action
        return action
    else:  # Chose a key
        key = _keys[x]
    if key != -1:
        action[key] = preset or _edit_keymatch_value(key, action.get(key))
        if not action[key]:
            action.pop(key)
    return self.METHOD_NAME(action, header)