private AddressSet selectDeadSubroutines(TaskMonitor monitor, Program program,
			AddressSet startAddresses) throws CancelledException {

		// Create a new address set to hold the entire selection.
		AddressSet newAddressSet = new AddressSet();
		// If we don't have any addresses simply return.
		if ((startAddresses == null) || (startAddresses.getNumAddresses() <= 0)) {
			return newAddressSet;
		}

		monitor.initialize(startAddresses.getNumAddresses());

		ReferenceManager rm = program.getReferenceManager();
		CodeBlockModel cbm = blockModelService.getActiveSubroutineModel();
		CodeBlockIterator cbIter = cbm.getCodeBlocksContaining(startAddresses, monitor);

		while (cbIter.hasNext()) {
			if (monitor.isCancelled()) {
				return newAddressSet;
			}

			CodeBlock block = cbIter.next();
			monitor.setMessage(block.getName());
			if (!blockHasReferences(rm, block)) {
				newAddressSet.add(block);
			}
			monitor.incrementProgress(block.getNumAddresses());
		}

		return newAddressSet;
	}
Selects subroutines that are not directly referenced. 
This is commonly referred to as DEAD code.
@param monitor a cancellable task monitor
@return address set containing the dead subroutines
@throws CancelledException
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/select/flow/SelectByFlowPlugin.java