* @param pattern
   * @param bindings
   * @return KeyValueList
   */
  public static KeyValueList matchConsTree(Stella_Object tree, Stella_Object pattern, KeyValueList bindings) {
    if (bindings == null) {
      bindings = KeyValueList.newKeyValueList();
    }
    if (pattern == Stella.SYM_STELLA_p) {
      return (bindings);
    }
    { Surrogate testValue000 = Stella_Object.safePrimaryType(pattern);

      if (Surrogate.subtypeOfSymbolP(testValue000)) {
        { Symbol pattern000 = ((Symbol)(pattern));

          if ((pattern000.symbolName).charAt(0) == '?') {
            { Stella_Object value = bindings.lookup(pattern000);

              if (value == null) {
                bindings.insertAt(pattern000, tree);
                return (bindings);
              }
              else if (Stella_Object.equalP(value, tree)) {
                return (bindings);
              }
            }
          }
          else {
            if (tree == pattern000) {
              return (bindings);
            }
          }
        }
      }
      else if (testValue000 == Stella.SGT_STELLA_CONS) {
        { Cons pattern000 = ((Cons)(pattern));

          if (Stella_Object.safePrimaryType(tree) == Stella.SGT_STELLA_CONS) {
            { Cons tree000 = ((Cons)(tree));

              { boolean testValue001 = false;

                testValue001 = tree000.length() == pattern000.length();
                if (testValue001) {
                  { boolean alwaysP000 = true;

                    { Stella_Object elt = null;
                      Cons iter000 = tree000;
                      Stella_Object pat = null;
                      Cons iter001 = pattern000;

                      loop000 : for (;(!(iter000 == Stella.NIL)) &&
                                (!(iter001 == Stella.NIL)); iter000 = iter000.rest, iter001 = iter001.rest) {
                        elt = iter000.value;
                        pat = iter001.value;
                        if (!(Stella_Object.matchConsTree(elt, pat, bindings) != null)) {
                          alwaysP000 = false;
                          break loop000;
                        }
                      }
                    }
                    testValue001 = alwaysP000;
                  }
                }
                if (testValue001) {
                  return (bindings);
                }
              }
            }
          }
          else {
          }
        }
      }
      else {
        if (Stella_Object.eqlP(tree, pattern)) {
          return (bindings);
        }
      }
    }
    return (null);
  }