public boolean removeElement(ElementKey<?,?> childKey,Element element){
  throwExceptionIfLocked();
  boolean removed=false;
  if (state.elements != null) {
    Object obj=getElementObject(childKey);
    if (obj instanceof Collection<?>) {
      Collection<Element> collect=castElementCollection(obj);
      Iterator<Element> iter=collect.iterator();
      while (iter.hasNext()) {
        if (iter.next() == element) {
          iter.remove();
          removed=true;
          break;
        }
      }
      if (collect.isEmpty()) {
        removeElement(childKey);
      }
    }
 else     if (obj == element) {
      removeElement(childKey);
      removed=true;
    }
  }
  return removed;
}

public boolean removeElement ( ElementKey < ? , ? > childKey , Element element ) { throwExceptionIfLocked ( ) ; boolean removed = false ; if ( state . elements != null ) { Object obj = getElementObject ( childKey ) ; if ( obj instanceof Collection < ? > ) { Collection < Element > collect = castElementCollection ( obj ) ; Iterator < Element > iter = collect . iterator ( ) ; while ( iter . hasNext ( ) ) { if ( iter . next ( ) == element ) { iter . remove ( ) ; removed = true ; break ; } } if ( collect . isEmpty ( ) ) { removeElement ( childKey ) ; } } else if ( obj == element ) { removeElement ( childKey ) ; removed = true ; } } return removed ; }
remove a single child element from this element . this method returns true if the element was found and removed , or false if it was not . it uses identity and not equality to find a match .
