def _check_item_type(item, field_name, allowed_types, expect_list=False,
    required_channels='all'):
    """
    Check the item's type against a set of allowed types.
    Vary the print message regarding whether the item can be None.
    Helper to `BaseRecord.check_field`.

    Parameters
    ----------
    item : any
        The item to check.
    field_name : str
        The field name.
    allowed_types : iterable
        Iterable of types the item is allowed to be.
    expect_list : bool, optional
        Whether the item is expected to be a list.
    required_channels : list, optional
        List of integers specifying which channels of the item must be
        present. May be set to 'all' to indicate all channels. Only used
        if `expect_list` is True, ie. item is a list, and its
        subelements are to be checked.

    Notes
    -----
    This is called by `check_field`, which determines whether the item
    should be a list or not. This function should generally not be
    called by the user directly.

    """
    if expect_list:
        if not isinstance(item, list):
            raise TypeError('Field `%s` must be a list.' % field_name)
        if required_channels == 'all':
            required_channels = list(range(len(item)))
        for ch in range(len(item)):
            if ch in required_channels:
                allowed_types_ch = allowed_types
            else:
                allowed_types_ch = allowed_types + (type(None),)
            if not isinstance(item[ch], allowed_types_ch):
                raise TypeError(
                    'Channel %d of field `%s` must be one of the following types:'
                     % (ch, field_name), allowed_types_ch)
    elif not isinstance(item, allowed_types):
        raise TypeError('Field `%s` must be one of the following types:',
            allowed_types)
