def to_technique_list(controls, mappings, attack, family_id_to_controls, family_id_to_name, id_to_family):
    """take a controls ms, a mappings ms, and attack_data ms
    return a list of Techniques where the score is the number of controls that map to the technique"""
    technique_to_mapped_controls = {}
    stixid_to_object = {obj["id"]: obj for obj in attack}
    stixid_to_object.update({obj["id"]: obj for obj in controls})
    for mapping in mappings:
        # source_ref is the control in controls
        if mapping["source_ref"] not in stixid_to_object:
            continue  # mapping not relevant to this list of controls
        control_id = stixid_to_object[mapping["source_ref"]]["external_references"][0]["external_id"]
        # target_ref is the technique in attack_data
        attack_id = stixid_to_object[mapping["target_ref"]]["external_references"][0]["external_id"]
        # build the mapping
        if attack_id in technique_to_mapped_controls:
            technique_to_mapped_controls[attack_id].append(control_id)
        else:
            technique_to_mapped_controls[attack_id] = [control_id]

    # collapse families where all controls are mapped; list just the family identifier
    for attack_id in technique_to_mapped_controls:
        control_ids = technique_to_mapped_controls[attack_id]
        # Group mapped controls for this technique according to the family
        families = {}
        for cid in control_ids:
            family_id = id_to_family.search(cid).groups()[0]
            if family_id not in families:
                families[family_id] = {cid}  # new set
            else:
                families[family_id].add(cid)  # add to set

        # are all controls in the family mapped?
        collapsed_controls = []
        for family_id in families:
            family_set = families[family_id]
            controls_in_family = set(c["external_references"][0]["external_id"]
                                     for c in family_id_to_controls[family_id])
            if family_set == controls_in_family:  # all controls in family mapped?
                # collapse
                collapsed_controls.append(f"all '{family_id_to_name[family_id]}' controls")
            else:
                collapsed_controls += control_ids
        technique_to_mapped_controls[attack_id] = collapsed_controls

    # remove duplicate mappings
    for attack_id in technique_to_mapped_controls:
        technique_to_mapped_controls[attack_id] = list(set(technique_to_mapped_controls[attack_id]))

    # transform to techniques
    return [technique(attack_id, technique_to_mapped_controls[attack_id])
            for attack_id in technique_to_mapped_controls]
take a controls ms, a mappings ms, and attack_data ms
    return a list of Techniques where the score is the number of controls that map to the technique
src/mappings_to_heatmaps.py