private Address checkRecordBeforeRange(Address paintStart, Address paintEnd, Field value)
			throws IOException {
		DBRecord record = getRecordBefore(paintStart);
		if (record == null) {
			return paintStart;
		}

		Address recordStart = getStartAddress(record);
		Address recordEnd = getEndAddress(record);
		Field recordValue = getValue(record);

		// if the previous record is in different address space, nothing to do, start doesn't change
		if (!recordEnd.hasSameAddressSpace(paintStart)) {
			return paintStart;
		}

		// if it has the same value as the new record, there are 3 cases:
		// 		the previous range extends past new range -> no need to paint the new range at all
		// 	    the previous range ends just before or into the new range -> delete old range and make new range 
		//				have previous range start
		// 		the previous range ends before this range -> no effect just leave the start the same
		if (recordValue.equals(value)) {
			// see if existing range already completely covers new range.
			if (recordEnd.compareTo(paintEnd) >= 0) {
				// return null to indicate no painting is needed
				return null;
			}

			if (recordEnd.isSuccessor(paintStart) || paintStart.compareTo(recordEnd) <= 0) {
				// otherwise, merge by deleting previous record and changing start to record's start
				rangeMapTable.deleteRecord(record.getKey());
				return recordStart;
			}
			// otherwise previous range is completely before, so has no effect
			return paintStart;
		}

		// different values, 3 cases to deal with
		// 	case 1: the previous range is before the new range -> do nothing
		//	case 2: the previous range ends inside the new range -> truncate previous range
		//  case 3: the previous range extends past the new range -> truncate previous ragne and
		// 			create a new region past where we are now painting

		// case 1, previous range is completely before new range, so nothing to do
		if (recordEnd.compareTo(paintStart) < 0) {
			return paintStart;
		}

		// in case 2 or 3 we need to truncate the previous record
		record.setLongValue(TO_COL, addressMap.getKey(paintStart.subtract(1), true));
		rangeMapTable.putRecord(record);

		// in case 3, we need to create a new record for the part of the previous record that
		// extends past our new range
		if (recordEnd.compareTo(paintEnd) > 0) {
			createRecord(paintEnd.add(1), recordEnd, recordValue);
		}

		return paintStart;
	}
Checks the record before our paint to see how it is affected. Returns a possible new start
address for our paint if it gets merged. Returns null if it turns out we don't need to
paint at all.

@param paintStart the start of the paint range
@param paintEnd the end of the paint range
@param value the value to associate with the range
@return a new start address for the paint or null if we don't need to paint at all
@throws IOException if a database I/O exception occurs
Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/util/AddressRangeMapDB.java