/**
  * Returns an list containing all graph cells taht have the same userObject like the graph cell
  * specified as the parameter.
  *
  * @param cell The graph cell with a userObject for which all graph cels should be found.
  * @return List
  */
 private List<Object> getCellsWithUserObject(DefaultGraphCell cell) {
   List<Object> cells = new ArrayList<Object>();
   if (cell != null) {
     Object userObject = getUserObject(cell);
     cells.addAll(getCellsWithUserObject(userObject));
   }
   return cells;
 }
 /**
  * Deselects all graph cells that have the same userObject as specified in the parameter.
  *
  * @param root The graph cell whose userObject will be considered.
  */
 private void removeAll(Object root) {
   if (root != null) {
     if (root instanceof DefaultGraphCell) {
       // the cell is a DefaultGraphCell
       DefaultGraphCell rootCell = (DefaultGraphCell) root;
       // get all graph cells that have the same userObject like the rootCell
       List<Object> list = getCellsWithUserObject(rootCell);
       if (list != null) {
         // deselect all the graph cells with the same userObject
         graph.getSelectionModel().removeSelectionCells(list.toArray());
       }
     }
   }
 }
 /**
  * Returns an list containing all graph cells taht have the same userObject.
  *
  * @param userObject The userObject for which all graph cels should be found.
  * @return java.util.List
  */
 private List<Object> getCellsWithUserObject(Object userObject) {
   List<Object> cells = new ArrayList<Object>();
   if (userObject != null) {
     // get the graph model, which contains all the cells of the graph
     GraphModel model = graph.getModel();
     // loop through all the cells of the model
     for (int i = 0; i < model.getRootCount(); i++) {
       Object root = model.getRootAt(i);
       // get the userObject for the curent graph cell
       Object rootUserObject = getUserObject(root);
       if (rootUserObject != null) {
         if (userObject == rootUserObject) {
           // the userObject of the current graph cell is teh same like the wanted userObject
           cells.add(root);
         }
       }
     }
   }
   return cells;
 }