public static Cons yieldInCursorClausesForGeneralCollection(Stella_Object collectiontree, StandardObject collectiontype, Symbol keyvar, Symbol valuevar, Object [] MV_returnarray) {
    { Surrogate collectionbasetype = StandardObject.typeSpecToBaseType(collectiontype);
      Symbol iteratorvar = Stella.localGensym("ITER");
      Cons iteratorclauses = Stella.NIL;
      Cons valueclauses = Stella.NIL;
      Stella_Object continuationtest = null;
      Cons keytree = Stella.NIL;
      Cons valuetree = Stella.NIL;
      Cons bumptrees = Stella.NIL;

      if (collectionbasetype == Stella.SGT_STELLA_LIST) {
        iteratorclauses = Cons.cons(Cons.cons(iteratorvar, Cons.list$(Cons.cons(Stella.SGT_STELLA_CONS, Cons.cons(Cons.list$(Cons.cons(Stella.SYM_STELLA_THE_CONS_LIST, Cons.cons(collectiontree, Cons.cons(Stella.NIL, Stella.NIL)))), Cons.cons(Stella.NIL, Stella.NIL))))), Stella.NIL);
        collectionbasetype = Stella.SGT_STELLA_CONS;
      }
      else if (collectionbasetype == Stella.SGT_STELLA_KEY_VALUE_LIST) {
        iteratorclauses = Cons.cons(Cons.cons(iteratorvar, Cons.list$(Cons.cons(Stella.SGT_STELLA_KV_CONS, Cons.cons(Cons.list$(Cons.cons(Stella.SYM_STELLA_THE_KV_LIST, Cons.cons(collectiontree, Cons.cons(Stella.NIL, Stella.NIL)))), Cons.cons(Stella.NIL, Stella.NIL))))), Stella.NIL);
        collectionbasetype = Stella.SGT_STELLA_KV_CONS;
      }
      else if (collectionbasetype == Stella.SGT_STELLA_PROPERTY_LIST) {
        iteratorclauses = Cons.cons(Cons.cons(iteratorvar, Cons.list$(Cons.cons(Stella.SGT_STELLA_CONS, Cons.cons(Cons.list$(Cons.cons(Stella.SYM_STELLA_THE_PLIST, Cons.cons(collectiontree, Cons.cons(Stella.NIL, Stella.NIL)))), Cons.cons(Stella.NIL, Stella.NIL))))), Stella.NIL);
      }
      else if ((collectionbasetype == Stella.SGT_STELLA_CONS) ||
          (collectionbasetype == Stella.SGT_STELLA_KV_CONS)) {
        iteratorclauses = Cons.cons(Cons.cons(iteratorvar, Cons.cons(collectionbasetype, Cons.cons(collectiontree, Stella.NIL))), Stella.NIL);
      }
      else {
        if (!(Surrogate.safeSubtypeOfP(collectionbasetype, Stella.SGT_STELLA_ABSTRACT_ITERATOR))) {
          collectiontree = Cons.list$(Cons.cons(Stella.SYM_STELLA_ALLOCATE_ITERATOR, Cons.cons(collectiontree, Cons.cons(Stella.NIL, Stella.NIL))));
        }
        iteratorclauses = Cons.cons(Cons.cons(iteratorvar, Cons.list$(Cons.cons(Stella.SGT_STELLA_ABSTRACT_ITERATOR, Cons.cons(collectiontree, Cons.cons(Stella.NIL, Stella.NIL))))), Stella.NIL);
        collectionbasetype = Stella.SGT_STELLA_ABSTRACT_ITERATOR;
      }
      if (keyvar != null) {
        keytree = Cons.list$(Cons.cons(Stella.SYM_STELLA_KEY, Cons.cons(iteratorvar, Cons.cons(Stella.NIL, Stella.NIL))));
      }
      valuetree = Cons.list$(Cons.cons(Stella.SYM_STELLA_VALUE, Cons.cons(iteratorvar, Cons.cons(Stella.NIL, Stella.NIL))));
      if (collectionbasetype == Stella.SGT_STELLA_CONS) {
        bumptrees = Cons.cons(Cons.list$(Cons.cons(Stella.SYM_STELLA_SETQ, Cons.cons(iteratorvar, Cons.cons(Cons.cons(Cons.list$(Cons.cons(Stella.SYM_STELLA_REST, Cons.cons(iteratorvar, Cons.cons(Stella.NIL, Stella.NIL)))), Stella.NIL), Stella.NIL)))), Stella.NIL);
        continuationtest = Cons.list$(Cons.cons(Stella.SYM_STELLA_NOT, Cons.cons(Cons.list$(Cons.cons(Stella.SYM_STELLA_NILp, Cons.cons(iteratorvar, Cons.cons(Stella.NIL, Stella.NIL)))), Cons.cons(Stella.NIL, Stella.NIL))));
      }
      else if (collectionbasetype == Stella.SGT_STELLA_KV_CONS) {
        bumptrees = Cons.cons(Cons.list$(Cons.cons(Stella.SYM_STELLA_SETQ, Cons.cons(iteratorvar, Cons.cons(Cons.cons(Cons.list$(Cons.cons(Stella.SYM_STELLA_REST, Cons.cons(iteratorvar, Cons.cons(Stella.NIL, Stella.NIL)))), Stella.NIL), Stella.NIL)))), Stella.NIL);
        continuationtest = Cons.list$(Cons.cons(Stella.SYM_STELLA_DEFINEDp, Cons.cons(iteratorvar, Cons.cons(Stella.NIL, Stella.NIL))));
      }
      else if (collectionbasetype == Stella.SGT_STELLA_PROPERTY_LIST) {
        if (keyvar != null) {
          keytree = Cons.list$(Cons.cons(Stella.SYM_STELLA_VALUE, Cons.cons(iteratorvar, Cons.cons(Stella.NIL, Stella.NIL))));
        }
        valuetree = Cons.list$(Cons.cons(Stella.SYM_STELLA_VALUE, Cons.cons(Cons.list$(Cons.cons(Stella.SYM_STELLA_REST, Cons.cons(iteratorvar, Cons.cons(Stella.NIL, Stella.NIL)))), Cons.cons(Stella.NIL, Stella.NIL))));
        bumptrees = Cons.cons(Cons.list$(Cons.cons(Stella.SYM_STELLA_SETQ, Cons.cons(iteratorvar, Cons.cons(Cons.cons(Cons.list$(Cons.cons(Stella.SYM_STELLA_REST, Cons.cons(Cons.list$(Cons.cons(Stella.SYM_STELLA_REST, Cons.cons(iteratorvar, Cons.cons(Stella.NIL, Stella.NIL)))), Cons.cons(Stella.NIL, Stella.NIL)))), Stella.NIL), Stella.NIL)))), Stella.NIL);
        continuationtest = Cons.list$(Cons.cons(Stella.SYM_STELLA_NOT, Cons.cons(Cons.list$(Cons.cons(Stella.SYM_STELLA_NILp, Cons.cons(iteratorvar, Cons.cons(Stella.NIL, Stella.NIL)))), Cons.cons(Stella.NIL, Stella.NIL))));
      }
      else if (collectionbasetype == Stella.SGT_STELLA_ABSTRACT_ITERATOR) {
        bumptrees = Stella.NIL;
        continuationtest = Cons.list$(Cons.cons(Stella.SYM_STELLA_NEXTp, Cons.cons(iteratorvar, Cons.cons(Stella.NIL, Stella.NIL))));
      }
      else {
        { OutputStringStream stream000 = OutputStringStream.newOutputStringStream();

          stream000.nativeStream.print("`" + collectionbasetype + "' is not a valid case option");
          throw ((StellaException)(StellaException.newStellaException(stream000.theStringReader()).fillInStackTrace()));
        }
      }
      iteratorclauses = Cons.cons(Cons.cons(valuevar, Cons.cons(StandardObject.extractParameterType(collectiontype, Stella.SYM_STELLA_ANY_VALUE, new Object[1]), Cons.cons(Stella.SYM_STELLA_NULL, Stella.NIL))), iteratorclauses);
      valueclauses = Cons.cons(Cons.list$(Cons.cons(Stella.SYM_STELLA_SETQ, Cons.cons(valuevar, Cons.cons(Cons.cons(valuetree, Stella.NIL), Stella.NIL)))), valueclauses);
      if (keyvar != null) {
        { StandardObject keytype = null;
          boolean parameterexistsP = false;

          { Object [] caller_MV_returnarray = new Object[1];

            keytype = StandardObject.extractParameterType(collectiontype, Stella.SYM_STELLA_ANY_KEY, caller_MV_returnarray);
            parameterexistsP = ((boolean)(((BooleanWrapper)(caller_MV_returnarray[0])).wrapperValue));
          }
          if (parameterexistsP) {
            iteratorclauses = Cons.cons(Cons.cons(keyvar, Cons.cons(keytype, Cons.cons(Stella.SYM_STELLA_NULL, Stella.NIL))), iteratorclauses);
            valueclauses = Cons.cons(Cons.list$(Cons.cons(Stella.SYM_STELLA_SETQ, Cons.cons(keyvar, Cons.cons(Cons.cons(keytree, Stella.NIL), Stella.NIL)))), valueclauses);
          }
          else {
            { Object old$PrintreadablyP$000 = Stella.$PRINTREADABLYp$.get();

              try {
                Native.setBooleanSpecial(Stella.$PRINTREADABLYp$, true);
                Stella.signalTranslationError();
                if (!(Stella.suppressWarningsP())) {
                  Stella.printErrorContext(">> ERROR: ", Stella.STANDARD_ERROR);
                  {
                    Stella.STANDARD_ERROR.nativeStream.println();
                    Stella.STANDARD_ERROR.nativeStream.println(" Illegal key variable specified for keyless collection `" + Stella_Object.deUglifyParseTree(collectiontype) + "'.");
                  }
;
                }

              } finally {
                Stella.$PRINTREADABLYp$.set(old$PrintreadablyP$000);
              }
            }
            { Cons _return_temp = Stella.NIL;

              MV_returnarray[0] = Stella.NIL;
              MV_returnarray[1] = Stella.NIL;
              MV_returnarray[2] = Stella.SYM_STELLA_FALSE;
              return (_return_temp);
            }
          }
        }
      }
      { Cons _return_temp = iteratorclauses;

        MV_returnarray[0] = valueclauses;
        MV_returnarray[1] = bumptrees;
        MV_returnarray[2] = continuationtest;
        return (_return_temp);
      }
    }
  }