code: public static Iterator makeIterator( Object obj, IType typeHint )
    {
      if( obj == null )
      {
        return null;
      }
  
      if( typeHint.isArray() &&
          (obj.getClass().isArray() || TypeSystem.getFromObject( obj ).isArray()) )
      {
        return new ArrayIterator( obj, typeHint );
      }
  
      if( obj instanceof Iterable )
      {
        return ((Iterable)obj).iterator();
      }
  
      if( obj instanceof Iterator )
      {
        return(Iterator)obj;
      }
  
      // Treat a string as a list of characters
      if( obj instanceof String )
      {
        return new StringIterator( (String)obj );
      }
  
      if( obj instanceof Number )
      {
        return new NumberIterator( (Number)obj );
      }
  
      // Oh well. Convert to a List of length one and iterate that single element.
      return Collections.nCopies( 1, obj ).iterator();
    }
docs: A helper method for creating Iterators for use with 'exists' and 'foreach'
  elements.  Primarily for use with generated Java code (not necessary for
  direct interpretation).