def get_layers_by_property(controls, mappings, attack_data, domain, x_mitre, version):
    """get layers grouping the mappings according to values of the given property"""
    property_name = x_mitre.split("x_mitre_")[1]  # remove prefix
    family_id_to_controls, family_id_to_name, id_to_family = parse_family_data(controls)

    # group controls by the property
    property_value_to_controls = {}

    def add_to_dict(value, control):
        if value in property_value_to_controls:
            property_value_to_controls[value].append(control)
        else:
            property_value_to_controls[value] = [control]

    # iterate through controls, grouping by property
    is_list_type = False
    for control in controls:
        if control["type"] != "course-of-action":
            continue
        value = control.get(x_mitre)
        if not value:
            continue
        if isinstance(value, list):
            is_list_type = True
            for v in value:
                add_to_dict(v, control)
        else:
            add_to_dict(value, control)

    out_layers = []
    for value in property_value_to_controls:
        # controls for the corresponding values
        controls_of_value = property_value_to_controls[value]
        techniques = to_technique_list(controls_of_value, mappings, attack_data,
                                       family_id_to_controls, family_id_to_name, id_to_family)
        if len(techniques) > 0:
            # build layer for this technique set
            out_layers.append({
                "outfile": os.path.join(f"by_{property_name}", f"{value}.json"),
                "layer": create_layer(
                    f"{property_name}={value} mappings",
                    f"techniques where the {property_name} of associated controls "
                    f"{'includes' if is_list_type else 'is'} {value}",
                    domain,
                    techniques,
                    version
                )
            })

    return out_layers
get layers grouping the mappings according to values of the given property
src/mappings_to_heatmaps.py