TreeNode parentNode = nodeList.get(0);
//Remove each of the child nodes
Collection<TreeNode> childNodes = parentNode.getChildNodes();
for (TreeNode childNode : childNodes) {
if (childNodeNames.contains(childNode.getName())) {
parentNode.removeChild(childNode);
}
}
if (!parentNode.hasChildNodes())
removeParentNode(parentNode);
}