private ProgramLocation adjustStartLocation(Program program, ProgramLocation start,
			AddressSetView trimmedSet, boolean forward) {

		ProgramLocation adjustedStart = start;
		if (adjustedStart != null && trimmedSet != null && !trimmedSet.isEmpty()) {
			Address minAddress = trimmedSet.getMinAddress();
			Address maxAddress = trimmedSet.getMaxAddress();
			if (forward && adjustedStart.getAddress().compareTo(minAddress) < 0) {
				return new ProgramLocation(program, minAddress);
			}
			else if (!forward && adjustedStart.getAddress().compareTo(maxAddress) > 0) {
				return new ProgramLocation(program, maxAddress);
			}
		}
		return adjustedStart;
	}
Adjust the address set depending on the start location and whether searching forward 
or backward. The address set is adjusted by removing addresses that are before the start
locations address when searching forward or after the start address when searching backwards.
@param program the program for the address set
@param startLocation the program location where the search will start.
@param view the address set to be searched.
@param forward true for a forward search and false for backward search.
@return the adjusted address set.
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/databasesearcher/ProgramDatabaseSearcher.java