VirtualFile () { final TreePath path = myTree.getSelectionPath(); if (path != null) { Object component = path.getLastPathComponent(); VirtualFile file = null; if (component instanceof MyFileNode) { component = ((MyFileNode)component).getParent(); } if (component instanceof MyDuplicatesNode) { file = ((MyDuplicatesNode)component).getUserObject().iterator().next(); } return file; } return null; }