private int countUndefineds(Program p, Address address, String undefinedString) {

		int undefinedCount = 1;
		Listing listing = p.getListing();
		AddressSet allAddressAfter = new AddressSet(p, address, p.getMaxAddress());
		AddressIterator iterator = allAddressAfter.getAddresses(address.next(), true);
		while (iterator.hasNext()) {
			Address next = iterator.next();
			Data undefined = listing.getUndefinedDataAt(next);
			if (undefined == null) {
				break;
			}

			String currentString = undefined.getDefaultValueRepresentation();
			if (!undefinedString.equalsIgnoreCase(currentString)) {
				break;
			}
			++undefinedCount;
		}
		return undefinedCount;
	}
This function tries to determine the fill value used by the current program.
The byte value occurring most is the winner.

@return filler value
@throws Exception
Ghidra/Features/Base/src/main/java/ghidra/app/analyzers/CondenseFillerBytesAnalyzer.java