public static Keyword nthElementSpecialist(ControlFrame frame, Keyword lastmove) {
    { Proposition proposition = frame.proposition;
      Stella_Object collectionarg = (proposition.arguments.theArray)[0];
      Stella_Object collection = Logic.argumentBoundTo(collectionarg);
      Stella_Object narg = (proposition.arguments.theArray)[1];
      Stella_Object n = Logic.argumentBoundTo(narg);
      Stella_Object elementarg = (proposition.arguments.theArray)[2];
      Stella_Object element = Logic.argumentBoundTo(elementarg);

      lastmove = lastmove;
      if (Logic.logicalCollectionP(collection)) {
        { int then = Stella.NULL_INTEGER;
          Vector arguments = ((Skolem)(collection)).definingProposition.arguments;
          int nargs = arguments.length() - 1;

          if (Stella_Object.integerP(n)) {
            then = IntegerWrapper.unwrapInteger(((IntegerWrapper)(n)));
            if (then < 0) {
              then = nargs + then;
            }
            if ((then >= 0) &&
                (then < nargs)) {
              return (Logic.selectTestResult(Logic.bindArgumentToValueP(elementarg, (arguments.theArray)[then], true), true, frame));
            }
          }
          else if ((n == null) &&
              (element != null)) {
            { Stella_Object arg = null;
              Vector vector000 = arguments;
              int index000 = 0;
              int length000 = vector000.length();
              int i = Stella.NULL_INTEGER;
              int iter000 = 0;
              int upperBound000 = nargs - 1;

              for (;(index000 < length000) &&
                        (iter000 <= upperBound000); index000 = index000 + 1, iter000 = iter000 + 1) {
                arg = (vector000.theArray)[index000];
                i = iter000;
                if (Stella_Object.eqlP(Logic.argumentBoundTo(arg), element)) {
                  return (Logic.selectTestResult(Logic.bindArgumentToValueP(narg, IntegerWrapper.wrapInteger(i), true), true, frame));
                }
              }
            }
          }
          else if ((n == null) &&
              (element == null)) {
            { AllPurposeIterator iterator = ((AllPurposeIterator)(((Iterator)(KeyValueList.dynamicSlotValue(frame.dynamicSlots, Logic.SYM_STELLA_ITERATOR, null)))));

              if (iterator == null) {
                iterator = ((AllPurposeIterator)(((Iterator)(arguments.allocateIterator()))));
                KeyValueList.setDynamicSlotValue(frame.dynamicSlots, Logic.SYM_STELLA_ITERATOR, iterator, null);
              }
              then = iterator.iteratorInteger;
              if ((then < nargs) &&
                  iterator.nextP()) {
                element = iterator.value;
                if (Logic.bindArgumentToValueP(narg, IntegerWrapper.wrapInteger(then), true) &&
                    Logic.bindArgumentToValueP(elementarg, element, true)) {
                  return (Logic.KWD_CONTINUING_SUCCESS);
                }
              }
            }
          }
        }
      }
      return (Logic.KWD_TERMINAL_FAILURE);
    }
  }