public static Address findFirstConflictingAddress(Program program, Address addr, int length,
			boolean ignoreUndefinedData) {
		AddressSet addrSet = new AddressSet(addr, addr.add(length - 1));
		DataIterator definedDataIter = program.getListing().getDefinedData(addrSet, true);
		Data data = null;
		while (definedDataIter.hasNext()) {
			Data d = definedDataIter.next();
			if (!ignoreUndefinedData || !Undefined.isUndefined(d.getDataType())) {
				data = d;
				break;
			}
		}
		InstructionIterator instructionIter = program.getListing().getInstructions(addrSet, true);
		Instruction instruction = instructionIter.hasNext() ? instructionIter.next() : null;
		if (data == null && instruction == null) {
			return null;
		}
		if (data == null) {
			return instruction.getMinAddress();
		}
		if (instruction == null) {
			return data.getMinAddress();
		}
		Address dataAddr = data.getMinAddress();
		Address instructionAddr = instruction.getAddress();
		if (dataAddr.compareTo(instructionAddr) < 0) {
			return dataAddr;
		}
		return instructionAddr;
	}
Finds the first conflicting address in the given address range.

@param program The program.
@param addr The starting address of the range.
@param length The length of the range.
@param ignoreUndefinedData True if the search should ignore {@link Undefined} data as a
  potential conflict, or false if {@link Undefined} data should trigger conflicts.
@return The address of the first conflict in the range, or null if there were no conflicts.
Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/data/DataUtilities.java