private AddressRange findGapRange(Address address) throws IOException {
		// initialize to entire address space
		Address gapStart = address.getAddressSpace().getMinAddress();
		Address gapEnd = address.getAddressSpace().getMaxAddress();

		// adjust if there is a wrapping record
		if (address.hasSameAddressSpace(addressMap.getImageBase())) {
			DBRecord wrappingRecord = getAddressWrappingRecord();
			if (wrappingRecord != null) {
				// if there is a wrapping address, subtract those ranges from our defaults
				gapStart = getEndAddress(wrappingRecord).add(1);
				gapEnd = getStartAddress(wrappingRecord).subtract(1);
			}
		}

		// if previous record exists, then gap start is really one past the end of that range
		DBRecord record = getRecordAtOrBefore(address);
		if (record != null) {
			Address endAddress = getEndAddress(record);
			if (endAddress.hasSameAddressSpace(address) && endAddress.compareTo(address) < 0) {
				gapStart = endAddress.add(1);
			}
		}

		// if a follow on record exists in our space, then gap end will be just before this range
		record = getRecordAfter(address);
		if (record != null) {
			Address startAddress = getStartAddress(record);
			if (startAddress.hasSameAddressSpace(address) && startAddress.compareTo(address) > 0) {
				gapEnd = startAddress.subtract(1);
			}
		}

		return new AddressRangeImpl(gapStart, gapEnd);
	}
Returns the bounding address range for the given address where all addresses in that
range have the same value (this also works for now value. i.e finding a gap)
@param address the address to find a range for
@return an address range that contains the given address and has all the same value
Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/util/AddressRangeMapDB.java