SimpleNode[] () { List<SimpleNode> result = new ArrayList<>(); TreePath[] selectionPaths = getSelectionPaths(); if (selectionPaths != null) { SimpleNode lastNode = null; for (TreePath selectionPath : selectionPaths) { SimpleNode nodeFor = getNodeFor(selectionPath); if (lastNode != null && lastNode.getClass() != nodeFor.getClass()) { return new SimpleNode[0]; } result.add(nodeFor); lastNode = nodeFor; } } return result.toArray(new SimpleNode[0]); }