public static Cons matchPatternElement(Symbol patternElement, Stella_Object datumElement) {
    if (Stella_Object.isaP(datumElement, Stella.SGT_STELLA_CONS)) {
      { Stella_Object datumType = ((((Cons)(datumElement)).value == Stella.SYM_STELLA_SPECIAL) ? ((Cons)(datumElement)).rest.value : ((Cons)(datumElement)).value);

        if (datumType == patternElement) {
          return (((Cons)(datumElement)));
        }
        else {
          return (Stella.NIL);
        }
      }
    }
    else if (((Cons)(Stella.$SPECIAL_SYMBOLS$.get())).memberP(patternElement)) {
      return (Stella.NIL);
    }
    else {
      { java.lang.reflect.Method function = Symbol.lookupFunction(patternElement).functionCode;
        Stella_Object match = ((Stella_Object)(edu.isi.stella.javalib.Native.funcall(function, null, new java.lang.Object [] {datumElement})));

        if (Surrogate.subtypeOfBooleanP(Stella_Object.safePrimaryType(match))) {
          { BooleanWrapper match000 = ((BooleanWrapper)(match));

            if (BooleanWrapper.coerceWrappedBooleanToBoolean(match000)) {
              return (Cons.consList(Cons.cons(patternElement, Cons.cons(datumElement, Stella.NIL))));
            }
            else {
              return (Stella.NIL);
            }
          }
        }
        else {
          if (match != null) {
            return (Cons.consList(Cons.cons(patternElement, Cons.cons(match, Stella.NIL))));
          }
          else {
            return (Stella.NIL);
          }
        }
      }
    }
  }