def METHOD_NAME(val):
    # type: (value_t) -> Any
    if not isinstance(val, value_t):
        raise AssertionError(val)
    UP_val = val
    with tagswitch(val) as case:
        if case(value_e.Null):
            return None
        elif case(value_e.Undef):
            return None
        elif case(value_e.Bool):
            val = cast(value.Bool, UP_val)
            return val.b
        elif case(value_e.Int):
            val = cast(value.Int, UP_val)
            return val.i
        elif case(value_e.Float):
            val = cast(value.Float, UP_val)
            return val.f
        elif case(value_e.Str):
            val = cast(value.Str, UP_val)
            return val.s
        elif case(value_e.BashArray):
            val = cast(value.BashArray, UP_val)
            return val.strs
        elif case(value_e.List):
            val = cast(value.List, UP_val)
            return list(map(METHOD_NAME, val.items))
        elif case(value_e.BashAssoc):
            val = cast(value.BashAssoc, UP_val)
            return val.d
        elif case(value_e.Dict):
            val = cast(value.Dict, UP_val)
            d = NewDict()  # type: Dict[str, value_t]
            for k, v in val.d.items():
                d[k] = METHOD_NAME(v)
            return d
        elif case(value_e.Eggex):
            return val  # passthrough
        elif case(value_e.Range):
            val = cast(value.Range, UP_val)
            return xrange(val.lower, val.upper)
        elif case(value_e.Func):
            val = cast(value.Func, UP_val)
            return val.callable
        elif case(value_e.Block):
            return val  # passthrough
        else:
            raise error.Expr(
                'Trying to convert unexpected type to pyobj: %r' % val,
                loc.Missing)