private boolean removeDescendantsFromList(List<GTreeNode> list) {
		List<GTreeNode> newList = new ArrayList<>();
		for (int i = 0; i < list.size(); i++) {
			GTreeNode destNode = list.get(i);
			for (int j = 0; j < list.size(); j++) {
				GTreeNode node = list.get(j);
				if (destNode == node) {
					continue;
				}
				if (node.isAncestor(destNode)) {
					newList.add(node);
				}
			}
		}
		for (int i = 0; i < newList.size(); i++) {
			list.remove(newList.get(i));
		}
		return newList.size() > 0;
	}
Remove descendant nodes from the list; having the parent node
is enough when folders are getting pasted.
Ghidra/Framework/Project/src/main/java/ghidra/framework/main/projectdata/actions/ProjectDataPasteAction.java