private void updateSubroutineActions() {
    	
    	// Remove old actions
    	if (actions != null) {
    		for (int i = 0; i < actions.length; i++) {
    			tool.removeAction(actions[i]);  
    			actions[i] = null;
    		}
    		actions = null;
    	}
    	HelpLocation loc = new HelpLocation("ProgramTreePlugin", "Modularize_By_Subroutine");
    	
    	// Create subroutine actions for each subroutine provided by BlockModelService
        final String[] subModels = blockModelService.getAvailableModelNames(BlockModelService.SUBROUTINE_MODEL);
       	if (subModels.length > 1) {  // Not needed if only one subroutine model
       		actions = new DockingAction[subModels.length];
	        for (int i = 0; i < subModels.length; i++) {
	        	final String modelName = subModels[i];
	            actions[i] = new DockingAction("Modularize By Subroutine [" + modelName + "]", this.getName()) {
	            	@Override
	            	public void actionPerformed(ActionContext context) {
                       	applyModuleAlgorithm(modelName, context.getContextObject());
	            	}
	            	@Override
	            	public boolean isEnabledForContext(ActionContext context) {
	            		if (context.getContextObject() instanceof ProgramNode) {
	            			return super.isEnabledForContext(context);
	            		}
	            		return false;
	            	}
	            };
// ACTIONS - auto generated
	            actions[i].setPopupMenuData( new MenuData( 
	            	new String[]{"Modularize By", "Subroutine", subModels[i]}, 
	            	null, 
	            	"select" ) );

        		tool.addAction(actions[i]); 
        		actions[i].setEnabled(currentProgram != null);
        		actions[i].setHelpLocation(loc);
	        }
       	} else {
       		actions = new DockingAction[1];
       		actions[0] = new DockingAction("Modularize By Subroutine", this.getName()) {
            	@Override
            	public void actionPerformed(ActionContext context) {
                   	applyModuleAlgorithm(null, context.getContextObject());
            	}
            	@Override
            	public boolean isEnabledForContext(ActionContext context) {
            		if (context.getContextObject() instanceof ProgramNode) {
            			return super.isEnabledForContext(context);
            		}
            		return false;
            	}
       		};
       		
       		actions[0].setPopupMenuData( new MenuData( 
       		    new String[] {"Modularize By", "Subroutine" }, "select" ) );
       		
            tool.addAction(actions[0]);	
    		actions[0].setEnabled(currentProgram != null); 
    		actions[0].setHelpLocation(loc);
       	}
    }
Applies the "module" algorithm to a Folder or Fragment. This algorithm first
applies the Multiple Entry Point Subroutine model, which generates fragments;
then the Partitioned Code Subroutine model is applied to the fragments.
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/algorithmtree/ModuleAlgorithmPlugin.java