AddressSet limitToStartofCodeUnits(Program program, AddressSetView initialSet) {
		Listing listing = program.getListing();
		AddressSet returnSet = new AddressSet();
		AddressIterator iter = initialSet.getAddresses(true);
		while (iter.hasNext()) {
			Address address = iter.next();
			CodeUnit cu = listing.getCodeUnitAt(address);
			if (cu != null) {
				// Only automerge functions that are still at a code unit after code unit merge.
				returnSet.addRange(address, address);
			}
		}
		return returnSet;
	}
Gets an address set indicating all addresses in the initial set that are the
minimum address of a code unit in the specified program's listing.
@param program the program to check for the start of each code unit.
@param initialSet the initial address set to be checked for the starts of code units.
@return the address set of all code unit min addresses in the initial set.
Ghidra/Features/Base/src/main/java/ghidra/app/merge/listing/FunctionMerger.java