public static Stella_Object lookupDeferredQueryOption(Stella_Object queryoroptions, Keyword key, Surrogate coercetotype) {
    { PropertyList options = null;
      PropertyList deferredoptions = null;
      Stella_Object value = null;
      Stella_Object coercedvalue = null;
      boolean processeddeferredoptionP = false;

      { Surrogate testValue000 = Stella_Object.safePrimaryType(queryoroptions);

        if (Surrogate.subtypeOfP(testValue000, Logic.SGT_STELLA_PROPERTY_LIST)) {
          { PropertyList queryoroptions000 = ((PropertyList)(queryoroptions));

            options = queryoroptions000;
          }
        }
        else if (Surrogate.subtypeOfP(testValue000, Logic.SGT_LOGIC_QUERY_ITERATOR)) {
          { QueryIterator queryoroptions000 = ((QueryIterator)(queryoroptions));

            options = queryoroptions000.options;
          }
        }
        else {
          { OutputStringStream stream000 = OutputStringStream.newOutputStringStream();

            stream000.nativeStream.print("`" + testValue000 + "' is not a valid case option");
            throw ((StellaException)(StellaException.newStellaException(stream000.theStringReader()).fillInStackTrace()));
          }
        }
      }
      deferredoptions = ((PropertyList)(options.lookup(Logic.KWD_DEFERRED_OPTIONS)));
      if (deferredoptions != null) {
        value = deferredoptions.lookup(key);
        if (value == null) {
          value = options.lookup(key);
        }
        else {
          processeddeferredoptionP = true;
        }
        if (value != null) {
          if (coercetotype != null) {
            coercedvalue = Stella_Object.coerceOptionValue(value, coercetotype);
            if (coercedvalue == null) {
              { OutputStringStream stream001 = OutputStringStream.newOutputStringStream();

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

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

                  } finally {
                    Stella.$PRINTREADABLYp$.set(old$PrintreadablyP$000);
                  }
                }
                throw ((ParsingError)(ParsingError.newParsingError(stream001.theStringReader()).fillInStackTrace()));
              }
            }
            else {
              value = coercedvalue;
            }
          }
          if (processeddeferredoptionP) {
            deferredoptions.removeAt(key);
            options.insertAt(key, value);
          }
        }
      }
      return (value);
    }
  }