* @param n
   * @param module
   * @param environment
   * @return Stella_Object
   */
  public static Stella_Object getNthValue(Stella_Object sequence, int n, Module module, Environment environment) {
    if ((n >= PLI.getColumnCount(sequence)) ||
        (n < 0)) {
      { OutputStringStream stream000 = OutputStringStream.newOutputStringStream();

        stream000.nativeStream.print("Column index `" + n + "' is out of range for `" + sequence + "'");
        throw ((LogicException)(LogicException.newLogicException(stream000.theStringReader()).fillInStackTrace()));
      }
    }
    { Surrogate testValue000 = Stella_Object.safePrimaryType(sequence);

      if (Surrogate.subtypeOfP(testValue000, Logic.SGT_LOGIC_PROPOSITION)) {
        { Proposition sequence000 = ((Proposition)(sequence));

          if (n == 0) {
            return (PLI.getPredicate(sequence000));
          }
          else {
            { Stella_Object value = (sequence000.arguments.theArray)[(n - 1)];

              if (Surrogate.subtypeOfP(Stella_Object.safePrimaryType(value), Logic.SGT_LOGIC_SKOLEM)) {
                { Skolem value000 = ((Skolem)(value));

                  { Module mdl000 = module;
                    Context cxt000 = mdl000;

                    if (mdl000 == null) {
                      mdl000 = ((Module)(Stella.$MODULE$.get()));
                      cxt000 = ((Context)(Stella.$CONTEXT$.get()));
                    }
                    { Object old$Module$000 = Stella.$MODULE$.get();
                      Object old$Context$000 = Stella.$CONTEXT$.get();

                      try {
                        Native.setSpecial(Stella.$MODULE$, mdl000);
                        Native.setSpecial(Stella.$CONTEXT$, cxt000);
                        environment = environment;
                        synchronized (Logic.$POWERLOOM_LOCK$) {
                          return (Logic.valueOf(value000));
                        }

                      } finally {
                        Stella.$CONTEXT$.set(old$Context$000);
                        Stella.$MODULE$.set(old$Module$000);
                      }
                    }
                  }
                }
              }
              else {
                return (value);
              }
            }
          }
        }
      }
      else if (Surrogate.subtypeOfP(testValue000, PLI.SGT_PLI_PL_ITERATOR)) {
        { PlIterator sequence000 = ((PlIterator)(sequence));

          return (PLI.getNthValue(sequence000.value, n, module, environment));
        }
      }
      else if (testValue000 == Logic.SGT_STELLA_CONS) {
        { Cons sequence000 = ((Cons)(sequence));

          return (sequence000.nth(n));
        }
      }
      else if (Surrogate.subtypeOfP(testValue000, Logic.SGT_STELLA_VECTOR)) {
        { Vector sequence000 = ((Vector)(sequence));

          return ((sequence000.theArray)[n]);
        }
      }
      else {
        return (sequence);
      }
    }
  }