import typing


def _is_union_of_any(type_):
    """Checks if type_ is Union[from_type, Any] or Union[from_type, Any, None]
    """

    if type_ == typing.Optional[typing.Any] or\
            getattr(type_, '__origin__', None) is not typing.Union or\
            typing.Any not in type_.__args__:
        return False
    return len(type_.__args__) == 2 or len(type_.__args__) == 3 and type(None) in type_.__args__