def flatten_type_dict(type_dict):
    """Flattens a nested dictionary

    Args:
        type_dict: dictionary of types that are generic

    Returns:
        flat_dict: flatten dictionary to a single level

    """
    flat_dict = {}
    for k, v in type_dict.items():
        if isinstance(v, dict):
            return_dict = flatten_type_dict(v)
            flat_dict.update(return_dict)
        else:
            flat_dict[k] = v
    return flat_dict