code: public static boolean getContainerNotOfType(EObject element, Class<? extends EObject> type,
  			OutParameter<EObject> container, OutParameter<EObject> directContainerChild) {
  		EObject previous = element;
  		EObject elt = element.eContainer();
  		while (elt != null) {
  			if (!type.isInstance(elt)) {
  				if (directContainerChild != null) {
  					directContainerChild.set(previous);
  				}
  				if (container != null) {
  					container.set(elt);
  				}
  				return true;
  			}
  			previous = elt;
  			elt = elt.eContainer();
  		}
  		return false;
  	}
docs: Returns the closest {@link EObject#eContainer() container object} that is not of the requested type.
  
  @param element the element to start from.
  @param type the unexpected type.
  @param container the container.
  @param directContainerChild the child of the container that is or contains the given element.
  @return {@code true} if the container was found.
  @since 0.5
  @see EcoreUtil2#getContainerOfType(EObject, Class)