public static void traceGoalTree(ControlFrame frame, int depth, Keyword lastmove) {
    if (lastmove == Logic.KWD_DOWN) {
      ControlFrame.unwindToChoicePointsBelowFrame(frame);
    }
    if ((frame.state == Logic.KWD_ITERATIVE_FORALL) &&
        (lastmove == Logic.KWD_DOWN)) {
      return;
    }
    if (Stella_Object.traceKeywordP(Logic.KWD_STATE_MACHINE)) {
      if (Surrogate.subtypeOfP(Stella_Object.safePrimaryType(frame), Logic.SGT_LOGIC_PARALLEL_CONTROL_FRAME)) {
        { ParallelControlFrame frame000 = ((ParallelControlFrame)(frame));

          System.out.print("P" + ControlFrame.debugFrameId(frame000));
        }
      }
      else {
        System.out.print("F" + ControlFrame.debugFrameId(frame));
      }
      if (frame.choicePointUnbindingOffset != Stella.NULL_INTEGER) {
        System.out.print("," + frame.choicePointUnbindingOffset + " ");
      }
      else {
        System.out.print("   ");
      }
      System.out.print(((((frame.truthValue == Logic.DEFAULT_TRUE_TRUTH_VALUE) ||
          (frame.truthValue == Logic.DEFAULT_FALSE_TRUTH_VALUE)) ? "D " : "S ")));
    }
    if ((frame.state == Logic.KWD_PARALLEL_STRATEGIES) ||
        ((frame.state == Logic.KWD_STRATEGY) &&
         (frame.currentStrategy == null))) {
      return;
    }
    if (!((lastmove == Logic.KWD_DOWN) &&
        (Stella.getQuotedTree("((:ATOMIC-GOAL :STRATEGY) \"/LOGIC\")", "/LOGIC").memberP(frame.state) &&
         ((((Keyword)(frame.nextStrategies.value)) == Logic.KWD_SPECIALIST) &&
          (!Stella_Object.traceKeywordP(Logic.KWD_STRATEGIES)))))) {
      Logic.printVerticalBars(depth);
    }
    if (lastmove == Logic.KWD_DOWN) {
      { Keyword testValue000 = frame.state;

        if ((testValue000 == Logic.KWD_ATOMIC_GOAL) ||
            (testValue000 == Logic.KWD_STRATEGY)) {
          if (((Keyword)(frame.nextStrategies.value)) == Logic.KWD_SPECIALIST) {
            {
              if (Stella_Object.traceKeywordP(Logic.KWD_STRATEGIES)) {
                System.out.print("TRY STRATEGIES: ");
              }
              return;
            }
          }
          else {
            {
              ControlFrame.printGoalInGoalTree(frame, depth);
              if (Stella_Object.traceKeywordP(Logic.KWD_STRATEGIES)) {
                System.out.println();
                Logic.printVerticalBars(depth);
                System.out.print("STRATEGY: ");
                return;
              }
            }
          }
        }
        else if (testValue000 == Logic.KWD_PATTERN) {
          if ((Stella.$TRACED_KEYWORDS$ != null) &&
              Stella.$TRACED_KEYWORDS$.membP(Logic.KWD_STRATEGIES)) {
            System.out.println();
          }
          { ControlFrame upframe = frame.up;

            if ((upframe != null) &&
                (((Proposition)(KeyValueList.dynamicSlotValue(upframe.dynamicSlots, Logic.SYM_LOGIC_ANTECEDENTS_RULE, null))) != null)) {
              ControlFrame.printRuleInGoalTree(frame, ((Proposition)(KeyValueList.dynamicSlotValue(upframe.dynamicSlots, Logic.SYM_LOGIC_ANTECEDENTS_RULE, null))), depth);
            }
            else {
              {
                if ((((QueryIterator)(Logic.$QUERYITERATOR$.get())) != null) &&
                    (((QueryIterator)(Logic.$QUERYITERATOR$.get())).partialMatchStrategy != null)) {
                  System.out.println();
                }
                if (frame.patternRecord.collectionList != null) {
                  System.out.print("COLLECTION: [");
                }
                else {
                  System.out.print("PATTERN: [");
                }
                { boolean firsttimeP = true;

                  { BooleanWrapper tv = null;
                    BooleanVector vector000 = frame.patternRecord.booleanVector;
                    int index000 = 0;
                    int length000 = vector000.length();

                    for (;index000 < length000; index000 = index000 + 1) {
                      tv = ((BooleanWrapper)((vector000.theArray)[index000]));
                      if (firsttimeP) {
                        firsttimeP = false;
                      }
                      else {
                        System.out.print(",");
                      }
                      if (BooleanWrapper.coerceWrappedBooleanToBoolean(tv)) {
                        System.out.print("T");
                      }
                      else {
                        System.out.print("F");
                      }
                    }
                  }
                }
                System.out.print("]");
              }
            }
          }
        }
        else {
          ControlFrame.printGoalInGoalTree(frame, depth);
        }
      }
    }
    else if (lastmove == Logic.KWD_UP_TRUE) {
      if (true) {
        System.out.print("| SUCC: ");
        { Object old$Printinframe$000 = Logic.$PRINTINFRAME$.get();

          try {
            Native.setSpecial(Logic.$PRINTINFRAME$, frame);
            ControlFrame.printVariableBindings(frame);

          } finally {
            Logic.$PRINTINFRAME$.set(old$Printinframe$000);
          }
        }
        { TruthValue truthvalue = frame.truthValue;

          if (truthvalue != null) {
            System.out.print("truth=" + TruthValue.truthValueToString(truthvalue, true));
          }
        }
      }
    }
    else if (lastmove == Logic.KWD_UP_FAIL) {
      System.out.print("| FAIL");
      { Keyword testValue001 = frame.state;

        if ((testValue001 == Logic.KWD_ATOMIC_GOAL) ||
            (testValue001 == Logic.KWD_STRATEGY)) {
          if (Stella_Object.traceKeywordP(Logic.KWD_STRATEGIES) &&
              (!(frame.nextStrategies == Stella.NIL))) {
            System.out.println();
            Logic.printVerticalBars(depth);
            System.out.print("TRY STRATEGIES: ");
            return;
          }
        }
        else {
        }
      }
      { TruthValue truthvalue = frame.truthValue;

        if ((truthvalue != null) ||
            (frame.partialMatchFrame != null)) {
          System.out.print(":");
        }
        if (truthvalue != null) {
          System.out.print(" truth=" + TruthValue.truthValueToString(truthvalue, true));
        }
      }
    }
    else {
      System.out.print("????: ");
    }
    if (Stella_Object.traceKeywordP(Logic.KWD_STATE_MACHINE)) {
      System.out.print(" state= " + frame.state + "  lastMove= " + lastmove + " depth= " + depth + " revPty?= " + frame.reversePolarityP);
    }
    if (!(frame.partialMatchFrame != null)) {
      System.out.println();
    }
    else {
      System.out.print(" ");
      if ((lastmove == Logic.KWD_DOWN) ||
          ((lastmove == Logic.KWD_UP_TRUE) ||
           (lastmove == Logic.KWD_UP_FAIL))) {
        frame.partialMatchFrame.traceFramePartialTruth(lastmove, Stella.STANDARD_OUTPUT);
        System.out.println();
      }
      else {
      }
    }
  }