void (PackageNode node, Set<? super PackageNode> result) { result.add(node); for (int i = 0; i < node.getChildCount(); i++){ final TreeNode child = node.getChildAt(i); if (child instanceof PackageNode packNode && !result.contains(packNode)) { getPackageNodesHierarchy(packNode, result); } } }