void () { Map<U, N> newNodes = createUserObjectMap(); for (U node : JBTreeTraverser.from(myStructure).withRoot(getRootObject())) { N treeNode = myNodeCache.get(node); newNodes.put(node, treeNode == null ? createNode(node) : treeNode); } List<N> oldNodes = new ArrayList<>(); for (Map.Entry<U, N> entry : myNodeCache.entrySet()) { if (!newNodes.containsKey(entry.getKey())) oldNodes.add(entry.getValue()); } myNodeCache = newNodes; for (N node : oldNodes) { if (node.getParent() != null) removeNodeFromParent(node); } refilter(); }