void (CheckedTreeNode node) { if (node.isLeaf()) { Object userObject = node.getUserObject(); if (node.isChecked() && userObject != null && nodeType.isAssignableFrom(userObject.getClass())) { //noinspection unchecked final T value = (T)userObject; if (filter != null && !filter.accept(value)) return; nodes.add(value); } } else { for (int i = 0; i < node.getChildCount(); i++) { final TreeNode child = node.getChildAt(i); if (child instanceof CheckedTreeNode) { collect((CheckedTreeNode)child); } } } }