private Element firstElement(Object obj){
  if (obj == null) {
    return null;
  }
  if (obj instanceof Element) {
    return (Element)obj;
  }
 else {
    Collection<Element> elementCollection=castElementCollection(obj);
    if (!elementCollection.isEmpty()) {
      sublistIterator=elementCollection.iterator();
      return sublistIterator.next();
    }
  }
  return null;
}

private Element firstElement ( Object obj ) { if ( obj == null ) { return null ; } if ( obj instanceof Element ) { return ( Element ) obj ; } else { Collection < Element > elementCollection = castElementCollection ( obj ) ; if ( ! elementCollection . isEmpty ( ) ) { sublistIterator = elementCollection . iterator ( ) ; return sublistIterator . next ( ) ; } } return null ; }
get the first element from either a singleton or a collection of elements . this method will also set the sublistiterator as a side effect of retrieving the first element in a collection .
