Object (Object object) { if (object instanceof GroupNode) { GroupNode node = (GroupNode)object; object = node.getSingleRoot(); } if (object instanceof FileNode) { FileNode node = (FileNode)object; PsiElement element = node.findFileSystemItem(node.getVirtualFile()); if (element == null || node.compacted == null) return element; if (isPackage(node.getIcon()) && node.getSettings().isFlattenPackages()) return element; ArrayDeque<PsiElement> deque = new ArrayDeque<>(); node.compacted.forEach(file -> { PsiFileSystemItem item = node.findFileSystemItem(file); if (item != null) deque.addFirst(item); }); if (deque.isEmpty()) return element; deque.addFirst(element); return deque.toArray(); } if (object instanceof NodeDescriptor) { object = ((NodeDescriptor<?>)object).getElement(); } if (object instanceof AbstractTreeNode) { object = ((AbstractTreeNode<?>)object).getValue(); } return object; }