public static Stella_Object kifTermToUntypedStellaTerm(Stella_Object tree) {
    { Surrogate testValue000 = Stella_Object.safePrimaryType(tree);

      if (Surrogate.subtypeOfSymbolP(testValue000)) {
        { Symbol tree000 = ((Symbol)(tree));

          return (Logic.kifSymbolToStellaSymbol(tree000));
        }
      }
      else if (testValue000 == Logic.SGT_STELLA_CONS) {
        { Cons tree000 = ((Cons)(tree));

          { Stella_Object operator = tree000.value;

            if (Stella_Object.isaP(operator, Logic.SGT_STELLA_CONS)) {
              return (Logic.kifTermToUntypedStellaTerm(Cons.cons(Logic.SYM_PL_KERNEL_KB_VALUE, tree000.concatenate(Stella.NIL, Stella.NIL))));
            }
            if (!Stella_Object.symbolP(operator)) {
              { OutputStringStream stream000 = OutputStringStream.newOutputStringStream();

                { Object old$PrintreadablyP$000 = Stella.$PRINTREADABLYp$.get();

                  try {
                    Native.setBooleanSpecial(Stella.$PRINTREADABLYp$, true);
                    {
                      stream000.nativeStream.println("PARSING ERROR: Bad first argument in KIF term: `" + operator + "'");
                      stream000.nativeStream.println("   Operator must be a symbol or an expression.");
                    }
;
                    Logic.helpSignalPropositionError(stream000, Logic.KWD_ERROR);

                  } finally {
                    Stella.$PRINTREADABLYp$.set(old$PrintreadablyP$000);
                  }
                }
                throw ((ParsingError)(ParsingError.newParsingError(stream000.theStringReader()).fillInStackTrace()));
              }
            }
            if (Logic.$KIF_SENTENCE_OPERATORS$.memberP(operator)) {
              return (Logic.kifSentenceToUntypedStellaSentence(tree000));
            }
            else if (Logic.termKifSpecialFormP(operator)) {
              { GeneralizedSymbol testValue001 = ((GeneralizedSymbol)(operator));

                if (testValue001 == Logic.SYM_LOGIC_THE) {
                  return (Logic.kifTheToStellaTheOnly(tree000));
                }
                else if (testValue001 == Logic.SYM_LOGIC_SETOFALL) {
                  return (Logic.kifSetofallToStellaSetofall(tree000));
                }
                else if (testValue001 == Logic.SYM_LOGIC_KAPPA) {
                  return (Logic.kifKappaToStellaKappa(tree000));
                }
                else if (testValue001 == Logic.SYM_LOGIC_LAMBDA) {
                  return (Logic.kifTermToUntypedStellaTerm(Logic.kifLambdaToStellaKappa(tree000)));
                }
                else if (testValue001 == Logic.SYM_STELLA_IF) {
                  tree000.secondSetter(Logic.kifSentenceToUntypedStellaSentence(tree000.rest.value));
                  Logic.changeKifExpressionsToStellaExpressions(tree000.rest.rest, true);
                  return (tree000);
                }
                else if (testValue001 == Logic.SYM_STELLA_COND) {
                  return (Logic.kifTermToUntypedStellaTerm(Logic.kifCondToIf(tree000.rest)));
                }
                else if ((testValue001 == Logic.SYM_STELLA_SETOF) ||
                    (testValue001 == Logic.SYM_LOGIC_LISTOF)) {
                  Logic.changeKifExpressionsToStellaExpressions(tree000.rest, true);
                  return (tree000);
                }
                else {
                  { OutputStringStream stream001 = OutputStringStream.newOutputStringStream();

                    stream001.nativeStream.print("`" + testValue001 + "' is not a valid case option");
                    throw ((StellaException)(StellaException.newStellaException(stream001.theStringReader()).fillInStackTrace()));
                  }
                }
              }
            }
            else {
              tree000.firstSetter(Logic.kifOperatorToInternalStella(((Symbol)(operator))));
              Logic.changeKifExpressionsToStellaExpressions(tree000.rest, true);
              return (tree000);
            }
          }
        }
      }
      else {
        return (tree);
      }
    }
  }