private int computeRemainingDelaySlots(Instruction instr) {

		if (!instr.isInDelaySlot()) {
			return instr.getDelaySlotDepth();
		}

		int count = 0;
		InstructionIterator iter =
			instr.getProgram().getListing().getInstructions(instr.getAddress(), false);
		iter.next(); // skip initial instr
		try {
			while (instr.isInDelaySlot() && iter.hasNext()) {
				Address prevAddr = instr.getMinAddress().subtractNoWrap(1);
				instr = iter.next();
				if (!prevAddr.equals(instr.getMaxAddress())) {
					Msg.error(this, "Missing delay-slotted instruction at " + prevAddr);
					return 0;
				}
			}
		}
		catch (AddressOverflowException e) {
			Msg.error(this, "Invalid delay-slot instruction at " + instr.getAddress());
			return 0;
		}
		return instr.getDelaySlotDepth() - count;
	}
Code units are compared between the indicated listings starting at the
indicated address. The listings are searched in forward address order
until the address is found where all the listings have a code unit
with the same maximum address.
@param listings the program listings in the order LATEST, MY, ORIGINAL.
@param start the address to start at.
@return the common address where code units end for all listings or null.
Ghidra/Features/Base/src/main/java/ghidra/app/merge/listing/CodeUnitMerger.java