private void replaceRefs(Address originAddress, boolean defaultsOnly) {
		Address resultAddress = originToResultTranslator.getAddress(originAddress);
		ReferenceManager originalRM = originProgram.getReferenceManager();
		ReferenceManager resultRM = resultProgram.getReferenceManager();
		Reference[] originRefs = originalRM.getReferencesFrom(originAddress);
		Reference[] resultRefs = resultRM.getReferencesFrom(resultAddress);
		HashMap<Reference, Reference> originToResultMap = new HashMap<>(); // OriginRef, ResultRef
		// Determine the result references to keep that match the origin references.
		for (Reference origRef : originRefs) {
			SourceType source = origRef.getSource();
			if (defaultsOnly && source != SourceType.DEFAULT) {
				continue; // Don't hold onto non-defaults.
			}
			Reference resultRef = DiffUtility.getReference(originToResultTranslator, origRef);
			originToResultMap.put(origRef, resultRef);
		}
		// Remove references we don't need any more or those that are there but not the same.
		for (Reference resultRef : resultRefs) {
			// Leave fallthroughs as they are, so the code unit merge can handle them.
			if (resultRef.getReferenceType().isFallthrough()) {
				continue;
			}
			if (!originToResultMap.containsKey(resultRef)) {
				resultRM.delete(resultRef);
			}
		}
		// Add the references that aren't there yet and those that weren't the same.

		for (Reference originRef : originToResultMap.keySet()) {
			// Leave fall-through as they are, so the code unit merge can handle them.
			if (originRef.getReferenceType().isFallthrough()) {
				continue;
			}
			Reference resultRef = originToResultMap.get(originRef);
			replaceReference(resultRef, originRef);
		}
	}
@param resultAddress
This address should be derived from program 1.
Ghidra/Features/Base/src/main/java/ghidra/program/util/ProgramMerge.java