List (DefaultMutableTreeNode node, boolean checkOnly) { if (node.getChildCount() == 0) { return Collections.emptyList(); } final List<DefaultMutableTreeNode> nodes = checkOnly ? new SmartList<>() : new ArrayList<>(node.getChildCount()); DefaultMutableTreeNode child = (DefaultMutableTreeNode)node.getFirstChild(); while (child != null) { if (child instanceof StructureNode) { final OutputEventQueue.NodeEvent event = (OutputEventQueue.NodeEvent)child.getUserObject(); if (event != null && event.getType() == OutputEventQueue.CHARACTERS) { if (event.getValue().trim().length() == 0) { child = child.getNextSibling(); continue; } } } nodes.add(child); if (checkOnly) return nodes; child = child.getNextSibling(); } return nodes; }