private boolean pasteGroup(ProgramDnDTree tree, ProgramNode destNode, ProgramNode nodeToPaste) {

		if (destNode.isFragment()) {
			// can paste either a fragment or a module onto a fragment;
			// for module->fragment, the end result is all code units in
			// descendant fragments are moved to the destination fragment.
			try {
				tree.mergeGroup(nodeToPaste.getGroup(), destNode.getFragment());
				actionManager.removeFromClipboard(tree, nodeToPaste);
				return true;

			}
			catch (ConcurrentModificationException e) {
				// ha!
			}
			catch (Exception e) {
				Msg.showError(this, null, null, "Error Merging Fragments", e);
			}
			return false;
		}

		ProgramModule targetModule = destNode.getModule();

		if (targetModule == null) {
			actionManager.clearCut(nodeToPaste);
			Msg.showError(this, null, "Paste from Clipboard Failed",
				"Paste of " + nodeToPaste + " at\n" + destNode.getName() + " is not allowed.");

			return false;
		}

		return pasteNode(tree, destNode, nodeToPaste);
	}
Manage paste operations for the Program Tree.
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/programtree/PasteManager.java