def check_allowed_references(get_allows_none, get_allowed_types, request, ref_dict):
    """Check the reference according to rules specific to requests.

    In case the ``ref_dict`` is ``None``, it will check if this is allowed for the
    reference at hand.
    Otherwise, it will check if the reference dict's key (i.e. the TYPE) is allowed.
    """
    if ref_dict is None:
        return get_allows_none(request)

    ref_type = list(ref_dict.keys())[0]
    return ref_type in get_allowed_types(request)