protected CodeBlock getSubroutine(Address mStartAddr, TaskMonitor monitor) throws CancelledException {
    	
		// create a holder for the blockSet
        AddressSet addrSet = new AddressSet();
        
        // Create the todoStack and initialize it with instr; also initialize the list for entryPts.
        LinkedList<Address> todoList = new LinkedList<Address>();
        todoList.addFirst(mStartAddr);
        
        CodeBlockModel bbModel = modelM.getBasicBlockModel();
        
        // Build model-O subroutine from basic blocks
        while (!todoList.isEmpty()) {
        	
        	if (monitor.isCancelled()) {
				throw new CancelledException();
			}
        
        	// Get basic block at the specified address 
        	Address a = todoList.removeLast();  
        	if (addrSet.contains(a))
			 {
				continue; // already processed this block   
			}
	        CodeBlock bblock = bbModel.getFirstCodeBlockContaining(a, monitor);
	        if (bblock == null) {
				continue;
			}
	        	
	        // Verify that the block contains instructions
	        if (listing.getInstructionAt(a) == null) {
				continue;
			}
	        	
	        // Add basic block to subroutine address set
	        addrSet.add(bblock);
        
        	// Process all destination references
        	CodeBlockReferenceIterator destIter = bblock.getDestinations(monitor);
        	while (destIter.hasNext()) {
        		CodeBlockReference destRef = destIter.next();
        		FlowType refFlowType = destRef.getFlowType();
        		if (refFlowType.isJump() || refFlowType.isFallthrough())
	            {
	            	// Add Jump and Fall-through destinations to the todoList
	            	todoList.add(destRef.getDestinationAddress());	
	            }
        	}       	
        } 	
    	return createSub(addrSet, mStartAddr);
    }
Get the subroutine code block which starts at the specified address which 
 is an entry point of a Model-M subroutine.

 Classes which extend this class should implement this method.

@param   mStartAddr = a Model-M subroutine entry point.
@param monitor task monitor which allows user to cancel operation.
@return  a subroutine code block or null if not found.
@throws CancelledException if the monitor cancels the operation.
Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/block/OverlapCodeSubModel.java