Locates the underlying generic whose structure and behavior are known.

    For example, the base generic of a type that inherits from `typing.Mapping[T, int]`
    is `typing.Mapping`.

def find_base_generic(type_):
    """Locates the underlying generic whose structure and behavior are known.

    For example, the base generic of a type that inherits from `typing.Mapping[T, int]`
    is `typing.Mapping`.
    """
    for t in type_.__mro__:
        if t.__module__ == typing.__name__:
            return first_origin(t)