private ProgramModule make_module(Listing listing, String moduleName,
				ProgramModule parent) {
			String modName = moduleName;

			int oneUp = 1;
			ProgramModule newMod = listing.getModule(programTreeName, moduleName);
			while (newMod == null) {
				try {
					newMod = parent.createModule(modName);
				}
				catch (DuplicateNameException e) {
					// ignore
				}
				modName = moduleName + "_" + oneUp;
				oneUp++;
			}
			return newMod;
		}
Background command that will create the new tree and organize it.
Ghidra/Extensions/sample/src/main/java/ghidra/examples/SampleProgramTreePlugin.java