public static boolean processAddition(
     final MTrimBar trimBar,
     MTrimContribution contribution,
     List<MTrimElement> contributions,
     HashSet<String> existingToolbarIds) {
   int idx = getIndex(trimBar, contribution.getPositionInParent());
   if (idx == -1) {
     return false;
   }
   for (MTrimElement item : contribution.getChildren()) {
     if (item instanceof MToolBar && existingToolbarIds.contains(item.getElementId())) {
       // skip this, it's already there
       continue;
     }
     MTrimElement copy = (MTrimElement) EcoreUtil.copy((EObject) item);
     if (DEBUG) {
       trace("addTrimContribution " + copy, trimBar.getWidget(), trimBar); // $NON-NLS-1$
     }
     trimBar.getChildren().add(idx++, copy);
     contributions.add(copy);
     if (copy instanceof MToolBar && copy.getElementId() != null) {
       existingToolbarIds.add(copy.getElementId());
     }
   }
   return true;
 }
 private static boolean containsMatching(List<MTrimElement> children, MTrimElement me) {
   for (MTrimElement element : children) {
     if (Util.equals(me.getElementId(), element.getElementId())
         && element.getClass().isInstance(me)
         && (element instanceof MToolBarSeparator || element instanceof MToolBar)) {
       return true;
     }
   }
   return false;
 }