public static Cons kifKappaToStellaKappa(Cons tree) {
    if (!(tree.length() >= 2)) {
      { OutputStringStream stream000 = OutputStringStream.newOutputStringStream();

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

          try {
            Native.setBooleanSpecial(Stella.$PRINTREADABLYp$, true);
            stream000.nativeStream.println("PARSING ERROR: Illegal KAPPA tree: `" + tree + "'.");
            Logic.helpSignalPropositionError(stream000, Logic.KWD_ERROR);

          } finally {
            Stella.$PRINTREADABLYp$.set(old$PrintreadablyP$000);
          }
        }
        throw ((ParsingError)(ParsingError.newParsingError(stream000.theStringReader()).fillInStackTrace()));
      }
    }
    { Cons sentences = tree.rest.rest;

      tree.secondSetter(Logic.kifVariableDeclarationsToStella(tree.rest.value, true));
      { ConsIterator it = sentences.allocateIterator();

        while (it.nextP()) {
          it.valueSetter(Logic.kifSentenceToUntypedStellaSentence(it.value));
        }
      }
      switch (sentences.length()) {
        case 0: 
          tree.rest.rest = Cons.cons(Logic.SYM_STELLA_TRUE, Stella.NIL);
        break;
        case 1: 
          tree.thirdSetter(tree.rest.rest.value);
        break;
        default:
          tree.rest.rest = Cons.cons(Cons.cons(Logic.SYM_STELLA_AND, sentences.concatenate(Stella.NIL, Stella.NIL)), Stella.NIL);
        break;
      }
      return (tree);
    }
  }