private boolean createPostRemoveEventSelectionPath(
     Entry removedEntry,
     Folder parent,
     int index,
     TreePath path,
     RepositoryTreeUtil treeUtil) {
   TreePath savedPath = path;
   List<DataEntry> dataEntries;
   List<Folder> subfolders;
   try {
     subfolders = parent.getSubfolders();
     dataEntries = parent.getDataEntries();
   } catch (RepositoryException e1) {
     return false; // could not fetch subfolders or data entries -> dont save tree path
   }
   int nextSelectionIndex = index - 1;
   if (removedEntry instanceof Folder) {
     if (nextSelectionIndex >= 0) {
       savedPath = savedPath.pathByAddingChild(subfolders.get(nextSelectionIndex));
     }
   } else {
     if (nextSelectionIndex > 0) {
       if (nextSelectionIndex < subfolders.size()) {
         savedPath = savedPath.pathByAddingChild(subfolders.get(nextSelectionIndex));
       } else {
         savedPath =
             savedPath.pathByAddingChild(
                 dataEntries.get(nextSelectionIndex - subfolders.size()));
       }
     }
   }
   treeUtil.saveSelectionPath(savedPath);
   return true;
 }
 @Override
 public void folderRefreshed(Folder folder) {
   TreeModelEvent e = makeChangeEvent(folder);
   final RepositoryTreeUtil treeUtil = new RepositoryTreeUtil();
   if (parentTree != null) {
     treeUtil.saveExpansionState(parentTree);
   }
   for (TreeModelListener l : listeners.getListeners(TreeModelListener.class)) {
     l.treeStructureChanged(e);
   }
   treeUtil.locateExpandedEntries();
   if (parentTree != null) {
     SwingUtilities.invokeLater(
         new Runnable() {
           @Override
           public void run() {
             treeUtil.restoreExpansionState(parentTree);
           }
         });
   }
 }