public static LogicObject findSelectionKeyWithEquivalents(Cons pattern) {
    { Cons candidatekeys = pattern.rest.rest;

      { Keyword testValue000 = ((Keyword)(pattern.value));

        if ((testValue000 == Logic.KWD_DEPENDENTS) ||
            (testValue000 == Logic.KWD_ISA)) {
        }
        else if (testValue000 == Logic.KWD_RELATION) {
          candidatekeys = candidatekeys.rest;
        }
        else if ((testValue000 == Logic.KWD_CONTEXT_PROPOSITIONS) ||
            (testValue000 == Logic.KWD_CONTEXT_INSTANCES)) {
          candidatekeys = candidatekeys.rest;
        }
        else {
          { OutputStringStream stream000 = OutputStringStream.newOutputStringStream();

            stream000.nativeStream.print("get-selection-key-equivalents: Can't yet handle pattern `" + pattern + "'");
            throw ((StellaException)(StellaException.newStellaException(stream000.theStringReader()).fillInStackTrace()));
          }
        }
      }
      { Stella_Object key = null;
        Cons iter000 = candidatekeys;

        for (;!(iter000 == Stella.NIL); iter000 = iter000.rest) {
          key = iter000.value;
          if (Surrogate.subtypeOfP(Stella_Object.safePrimaryType(key), Logic.SGT_LOGIC_LOGIC_OBJECT)) {
            { LogicObject key000 = ((LogicObject)(key));

              if (!(key000.variableValueInverse() == Stella.NIL)) {
                return (key000);
              }
            }
          }
          else {
          }
        }
      }
      return (null);
    }
  }