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; }