def update_relationships(malware_subject_list, id_mappings):
    """Update any existing Malware Subject relationships to account for merged Malware Subjects"""
    for malware_subject in malware_subject_list:
        if malware_subject.relationships:
            relationships = malware_subject.relationships
            for relationship in relationships:
                malware_subject_references = (relationship.
                    malware_subject_references)
                for malware_subject_reference in malware_subject_references:
                    if (malware_subject_reference.malware_subject_idref in
                        id_mappings.keys()):
                        malware_subject_reference.malware_subject_idref = (
                            id_mappings[malware_subject_reference.
                            malware_subject_idref])
