import warnings


def filter_records_for_filetypes(records: dict, return_types: list):
    """ Find the records that have all the requested filetypes. e.g. get all subdirectories with labels """
    valid_records = {}
    for k, v in records.items():
        # k is the key for this record, e.g. experiment00_mouse00
        # v is the dictionary with files found for this record, e.g.
        # {rgb: movie.avi, label: labels.csv, flow: None, output: None}
        all_present = True
        for t in return_types:
            if v[t] is None:
                warnings.warn('No {} file found in record: {}'.format(t, k))
                all_present = False
        if all_present:
            valid_records[k] = v
    return valid_records