List<UsageInfo> () { TreePath[] paths = myTree.getSelectionPaths(); if (paths == null) return null; final ArrayList<UsageInfo> result = new ArrayList<>(); for (TreePath path : paths) { SliceNode sliceNode = fromPath(path); if (sliceNode != null) { final SliceUsage sliceUsage = sliceNode.getValue(); if (sliceUsage != null) { result.add(sliceUsage.getUsageInfo()); } } } if (result.isEmpty()) return null; return result; }