def METHOD_NAME(what, r_index):
    def _replace(str, loc, toks):
        ret = {'token' : what, 'orig' : []}
        orig = toks[0]
        r_orig = orig[r_index]
        if isinstance(r_orig, dict) and (r_orig['token'] == 'KW_Region'):
            orig = list(orig[:r_index]) + r_orig['orig']
        ret['orig'] = orig
        return ret
    return _replace