/**
  * Iterate just the elements of the collection that are already there. Don't load any new elements
  * from the database.
  */
 public static Iterator getLoadedElementsIterator(
     SessionImplementor session, CollectionType collectionType, Object collection) {
   if (collectionIsInitialized(collection)) {
     // handles arrays and newly instantiated collections
     return collectionType.getElementsIterator(collection, session);
   } else {
     // does not handle arrays (thats ok, cos they can't be lazy)
     // or newly instantiated collections, so we can do the cast
     return ((PersistentCollection) collection).queuedAdditionIterator();
   }
 }
 /**
  * Given a collection, get an iterator of all its children, loading them from the database if
  * necessary.
  *
  * @param session The session within which the cascade is occuring.
  * @param collectionType The mapping type of the collection.
  * @param collection The collection instance.
  * @return The children iterator.
  */
 private static Iterator getAllElementsIterator(
     EventSource session, CollectionType collectionType, Object collection) {
   return collectionType.getElementsIterator(collection, session);
 }