void (JTree tree, TreePath path, Collection<? super String> strings, int level, boolean withSelection, @Nullable Queryable.PrintInfo printInfo, @Nullable Predicate<? super String> nodePrintCondition) { Object pathComponent = path.getLastPathComponent(); Object userObject = TreeUtil.getUserObject(pathComponent); String nodeText = toString(userObject, printInfo); if (nodePrintCondition != null && !nodePrintCondition.test(nodeText)) { return; } StringBuilder buff = new StringBuilder(); StringUtil.repeatSymbol(buff, ' ', level); boolean expanded = tree.isExpanded(path); int childCount = tree.getModel().getChildCount(pathComponent); if (childCount > 0) { buff.append(expanded ? '-' : '+'); } boolean selected = tree.getSelectionModel().isPathSelected(path); if (withSelection && selected) { buff.append('['); } buff.append(nodeText); if (withSelection && selected) { buff.append(']'); } strings.add(buff.toString()); if (expanded) { for (int i = 0; i < childCount; i++) { TreePath childPath = path.pathByAddingChild(tree.getModel().getChild(pathComponent, i)); printImpl(tree, childPath, strings, level + 1, withSelection, printInfo, nodePrintCondition); } } }