DepTreeNode implements Cloneable, Serializable { public void prune() { if (children != null) { List<String> removeList = new ArrayList<String>(); for (Entry<String, DepTreeNode> entry : children.entrySet()) { DepTreeNode child = entry.getValue(); child.prune(); if ((child.defineDependencies == null && child.requireDependencies == null && child.uri == null) && (child.children == null || child.children.isEmpty())) { removeList.add(entry.getKey()); } } for (String key : removeList) { children.remove(key); } } } DepTreeNode(String name, URI uri); String getName(); long lastModified(); long lastModifiedDep(); long lastModifiedDepTree(); DepTreeNode getParent(); DepTreeNode getRoot(); String[] getDefineDepArray(); String[] getRequireDepArray(); String[] getDependentFeatures(); String getParentPath(); String getFullPathName(); void add(DepTreeNode child); void overlay(DepTreeNode node); void addAll(Collection<DepTreeNode> children); DepTreeNode createOrGet(String path, URI uri); DepTreeNode getDescendent(String path); void remove(DepTreeNode child); void removeAll(); Map<String, DepTreeNode> getChildren(); DepTreeNode getChild(String name); void prune(); void setDependencies(String[] defineDependencies, String[] requireDependencies, String[] dependentFeatures, long lastModifiedFile, long lastModifiedDep); @Override String toString(); String toStringTree(); @Override DepTreeNode clone(); IConfig getConfig();  }
@Test public void testPrune() { DepTreeNode root = new DepTreeNode("root", null); root.createOrGet("a", null); root.createOrGet("b", null); root.createOrGet("c", null); root.createOrGet("d", null); root.createOrGet("a/a", null); root.createOrGet("a/b", null); root.createOrGet("a/b/a", null); root.createOrGet("a/b/b", URI.create("a/b/b")); root.getDescendent("a/b").setDependencies(new String[]{"dep"}, new String[0], new String[0], 0L, 0L); root.getDescendent("c").setDependencies(new String[]{"dep"}, new String[0], new String[0], 0L, 0L); root.getDescendent("a/b/a").setDependencies(new String[]{"dep"}, new String[0], new String[0], 0L, 0L); root.prune(); assertNotNull(root.getChild("a")); assertNotNull(root.getChild("c")); assertNull(root.getChild("b")); assertNull(root.getChild("d")); assertNotNull(root.getDescendent("a/b")); assertEquals(null, root.getDescendent("a/a")); assertNotNull(root.getDescendent("a/b/a")); assertNotNull(root.getDescendent("a/b/b")); }