private Reference removeOldReference(List<Reference> oldRefList, Address toAddr, int opIndex,
			RefType refType) {
		if (oldRefList == null) {
			return null;
		}
		Iterator<Reference> iterator = oldRefList.iterator();
		while (iterator.hasNext()) {
			Reference ref = iterator.next();
			if (opIndex == ref.getOperandIndex() && toAddr.equals(ref.getToAddress())) {
				iterator.remove();
				if (refType == ref.getReferenceType()) {
					return ref;
				}
				break; // return null - can't re-use due to refType change
			}
		}
		return null;
	}
Remove matching memory reference from oldRefList (considers toAddr and opIndex only)
@param oldRefList list of existing DEFAULT memory references (may be null)
@param toAddr new reference destination address
@param opIndex new reference operand
@param refType new reference type
@return existing reference if it already exists in oldRefList with matching refType, else null
Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/code/CodeManager.java