@Override
	public boolean hasNext() throws CancelledException {
		if (nextSub != null) {
			return true;
		}

		Address addr = addrSet.getMinAddress();
		if (addr == null) {
			return false;
		}

		if (addr.isExternalAddress()) {
			nextSub = model.getCodeBlockAt(addr, monitor);
			addrSet.deleteRange(addr, addr);
			return true;
		}

		Instruction instr = listing.getInstructionAt(addr);
		if (instr == null) {
			addrSet.deleteRange(addr, addr);
		}

		while (instr == null) {

			if (monitor != null && monitor.isCancelled())
				throw new CancelledException();

			instr = listing.getInstructionAfter(addr);

			// If no more instructions we are done
			if (instr == null) {
				addrSet.clear();
				return false;
			}

			// Clear skipped addresses 
			Address minAddr = instr.getMinAddress();
			boolean setHadMinAddr = addrSet.contains(minAddr);
			addrSet.deleteRange(addr, minAddr);
			if (setHadMinAddr) {
				addrSet.addRange(minAddr, minAddr);
			}

			addr = minAddr;

			// If this instruction not in current set, repeat loop
			if (!addrSet.contains(addr)) {
				instr = null;
				addr = addrSet.getMinAddress();
				if (addr == null) {
					return false;
				}
			}
		}

		// Get code block which contains instruction address
		nextSub = model.getFirstCodeBlockContaining(addr, monitor);
		addrSet.delete(nextSub);
		return true;
	}
@see ghidra.program.model.block.CodeBlockIterator#hasNext()
Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/block/MultEntSubIterator.java