def get_study_uid_dict(checked_uids, parsed_dicom_data, multi_plan_only=False):
    """
    This thread iterates through self.checked_uids which contains plan uids, but we need to iterate through
    study instance uids so that plans on the same study are imported adjacently.
    :return: a dictionary with study uids for the keys and a list of associated plan uids for values
    :rtype: dict
    """
    study_uids = {}
    for plan_uid in checked_uids:
        study_uid = parsed_dicom_data[plan_uid
            ].study_instance_uid_to_be_imported
        if study_uid not in list(study_uids):
            study_uids[study_uid] = []
        study_uids[study_uid].append(plan_uid)
    if multi_plan_only:
        for study_uid in list(study_uids):
            if len(study_uids[study_uid]) < 2:
                study_uids.pop(study_uid)
    return study_uids
