public static Keyword leveledQuerySpecialist(ControlFrame frame, Keyword lastmove) {
    { Proposition proposition = frame.proposition;
      SavedInferenceLevelProofAdjunct adjunct = ((SavedInferenceLevelProofAdjunct)(((ProofAdjunct)(KeyValueList.dynamicSlotValue(frame.dynamicSlots, Logic.SYM_LOGIC_PROOF_ADJUNCT, null)))));

      if (lastmove == Logic.KWD_DOWN) {
        if (adjunct == null) {
          { Stella_Object argpropvalue = Logic.argumentBoundTo((proposition.arguments.theArray)[0]);

            if ((argpropvalue == null) ||
                (!Stella_Object.isaP(argpropvalue, Logic.SGT_LOGIC_PROPOSITION))) {
              return (Logic.KWD_TERMINAL_FAILURE);
            }
            { SavedInferenceLevelProofAdjunct self001 = SavedInferenceLevelProofAdjunct.newSavedInferenceLevelProofAdjunct();

              self001.savedInferenceLevel = Logic.currentInferenceLevel();
              self001.inferenceLevel = Logic.leveledQueryRelationToInferenceLevel(((Surrogate)(proposition.operator)));
              self001.downFrame = ControlFrame.createDownFrame(frame, ((Proposition)(argpropvalue)));
              adjunct = self001;
            }
            KeyValueList.setDynamicSlotValue(frame.dynamicSlots, Logic.SYM_LOGIC_PROOF_ADJUNCT, adjunct, null);
          }
        }
        frame.down = adjunct.downFrame;
        Logic.callSetInferenceLevel(adjunct.inferenceLevel.keyword, null);
        Native.setSpecial(Logic.$INFERENCELEVEL$, ((NormalInferenceLevel)(adjunct.inferenceLevel)));
        return (Logic.KWD_MOVE_DOWN);
      }
      else if (lastmove == Logic.KWD_UP_TRUE) {
        ControlFrame.propagateFrameTruthValue(frame.result, frame);
        if ((((QueryIterator)(Logic.$QUERYITERATOR$.get())) != null) &&
            (((QueryIterator)(Logic.$QUERYITERATOR$.get())).partialMatchStrategy != null)) {
          frame.result.partialMatchFrame.propagateFramePartialTruth(frame);
        }
        if (((Boolean)(Logic.$RECORD_JUSTIFICATIONSp$.get())).booleanValue()) {
          { Justification self002 = Justification.newJustification();

            self002.inferenceRule = Logic.KWD_LEVELED_QUERY;
            self002.antecedents = Cons.cons(((Justification)(KeyValueList.dynamicSlotValue(frame.result.dynamicSlots, Logic.SYM_LOGIC_JUSTIFICATION, null))), Stella.NIL);
            ControlFrame.recordGoalJustification(frame, self002);
          }
        }
        Logic.callSetInferenceLevel(adjunct.savedInferenceLevel.keyword, null);
        Native.setSpecial(Logic.$INFERENCELEVEL$, ((NormalInferenceLevel)(adjunct.savedInferenceLevel)));
        if (frame.down != null) {
          adjunct.downFrame = frame.down;
          frame.down = null;
          return (Logic.KWD_CONTINUING_SUCCESS);
        }
        else {
          return (Logic.KWD_FINAL_SUCCESS);
        }
      }
      else if (lastmove == Logic.KWD_UP_FAIL) {
        ControlFrame.propagateFrameTruthValue(frame.result, frame);
        if ((((QueryIterator)(Logic.$QUERYITERATOR$.get())) != null) &&
            (((QueryIterator)(Logic.$QUERYITERATOR$.get())).partialMatchStrategy != null)) {
          frame.result.partialMatchFrame.propagateFramePartialTruth(frame);
        }
        if (((Boolean)(Logic.$RECORD_JUSTIFICATIONSp$.get())).booleanValue()) {
          ControlFrame.recordPrimitiveJustification(frame, Logic.KWD_UP_FAIL);
        }
        Logic.callSetInferenceLevel(adjunct.savedInferenceLevel.keyword, null);
        Native.setSpecial(Logic.$INFERENCELEVEL$, ((NormalInferenceLevel)(adjunct.savedInferenceLevel)));
        return (Logic.KWD_FAILURE);
      }
      else {
        { OutputStringStream stream000 = OutputStringStream.newOutputStringStream();

          stream000.nativeStream.print("`" + lastmove + "' is not a valid case option");
          throw ((StellaException)(StellaException.newStellaException(stream000.theStringReader()).fillInStackTrace()));
        }
      }
    }
  }