private static int getDestinations(CodeBlock block, List<CodeBlockReference> blockRefQueue, TaskMonitor monitor) throws CancelledException {
    	
    	if (block == null || block.getMinAddress() == null) {
            return 0;
        }

        int count = 0;

		CodeBlockModel model = block.getModel();
		boolean includeExternals = model.externalsIncluded();

        // Iterate over all basic blocks within specified block
        CodeBlockIterator bblockIter = (model.getBasicBlockModel()).getCodeBlocksContaining(block, monitor);
        while (bblockIter.hasNext()) {

			// Get next basic block
			CodeBlock bblock = bblockIter.next();
			
			// Get basic block destinations
			CodeBlockReferenceIterator bbDestIter = bblock.getDestinations(monitor);
			while (bbDestIter.hasNext()) {
				CodeBlockReference bbDestRef = bbDestIter.next();
				FlowType refFlowType = bbDestRef.getFlowType();
				Address destAddr = bbDestRef.getReference();
				boolean addBlockRef = false;
				if (destAddr.isExternalAddress()) {
					if (includeExternals) {
						// Add all forward external references to queue if includeExternals
						addBlockRef = true;
					}
				}
				else if (refFlowType.isCall()) {
					// Add all forward CALL references to queue
					addBlockRef = true;
                }
                else if (refFlowType.isJump() || refFlowType.isFallthrough()) {		
                	// Add forward external JUMP and FALL-THROUGH references to queue
                	if (!block.contains(destAddr)) {
                		addBlockRef = true;
                    }
                }
				if (addBlockRef) {
					queueDestReferences(blockRefQueue,
										block, 
										bbDestRef.getReferent(), 
										destAddr, 
										refFlowType);
					count++;
				}
			}			
        }
		return count;
    }
Count and queue all destination references flowing out of this subroutine (block).
All Calls from this block, and all external FlowType block references
from this block are counted.

@param block code block to get the number of destination references from.
@param blockRefQueue the CodeBlockReference queue, may be null
@param includeExternals external references will be included if true
@param monitor task monitor
Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/block/SubroutineDestReferenceIterator.java