def get_data_ref_list(butler, run, **kwargs):
    """Construct and return a list of data_ids.

    Parameters
    ----------
    butler : `Bulter`
        The data Butler
    run : `str`
        The number number we are reading

    Keywords
    --------
    imagetype : `str`
        The type of image, e.g., BIAS or DARK or FLAT
    testtype : `str` or `list`
        The type of tests to collect visits from
    detectorname : `str`
        The name of the slot, e.g., S00, S11, ...
    nfiles : `int`
        Number of files per test to use, default is to use all

    Returns
    -------
    data_ref_list : `list`
        List of the visit IDs
    """
    testtype = kwargs.get('testtype', None)
    detectorname = kwargs.get('detectorname', None)
    raftname = kwargs.get('raftname', None)
    nfiles = kwargs.get('nfiles', None)

    if isinstance(testtype, str):
        testtypes = [testtype]
    elif isinstance(testtype, list):
        testtypes = testtype
    elif testtype is None:
        testtypes = []
    else:
        raise TypeError("testtype must be a list or str or None")

    data_id = dict(run=run, imagetype=kwargs.get('imagetype', 'BIAS'))
    if detectorname is not None:
        data_id['detectorname'] = detectorname
    if raftname is not None:
        data_id['raftname'] = raftname

    data_ref_list = []
    for testtype in testtypes:
        data_id['testtype'] = testtype.upper()
        subset = butler.subset("raw", '', data_id)
        if nfiles is None:
            data_ref_list += subset.cache
        else:
            data_ref_list += subset.cache[0:min(nfiles, len(subset.cache))]
    return data_ref_list