private CodeBlockVertex createRoot(GDirectedGraph<CodeBlockVertex, CodeBlockEdge> graph,
			String name) {

		Set<CodeBlockVertex> entryPoints = GraphAlgorithms.getEntryPoints(graph);
		if (entryPoints.size() == 1) {
			return entryPoints.iterator().next();
		}

		CodeBlockVertex nexus = new CodeBlockVertex(name);
		graph.addVertex(nexus);

		for (CodeBlockVertex entry : entryPoints) {
			CodeBlockEdge e = new CodeBlockEdge(nexus, entry);
			graph.addEdge(e);
		}
		return nexus;
	}
this code will apply the Dominance algorithm to a module or fragment in
a program tree.  First the code generates a call graph and from there a
dominance graph and finally a dominance structure in the program tree.
Ghidra/Features/Base/src/main/java/ghidra/app/cmd/module/DominanceModularizationCmd.java