public static List findMatchableGoals(Proposition forallprop, Keyword headortail) {
    { int index = ((headortail == Logic.KWD_HEAD) ? 1 : 0);
      Proposition proposition = ((Proposition)((forallprop.arguments.theArray)[index]));
      Cons variables = Stella.NIL;
      List resultlist = List.newList();

      { PatternVariable v = null;
        Vector vector000 = ((Vector)(KeyValueList.dynamicSlotValue(forallprop.dynamicSlots, Logic.SYM_LOGIC_IO_VARIABLES, null)));
        int index000 = 0;
        int length000 = vector000.length();

        for (;index000 < length000; index000 = index000 + 1) {
          v = ((PatternVariable)((vector000.theArray)[index000]));
          variables = Cons.cons(v, variables);
        }
      }
      if (variables.length() > 1) {
        if (headortail == Logic.KWD_TAIL) {
          { Keyword testValue000 = proposition.kind;

            if (testValue000 == Logic.KWD_AND) {
              { Stella_Object g = null;
                Vector vector001 = proposition.arguments;
                int index001 = 0;
                int length001 = vector001.length();

                for (;index001 < length001; index001 = index001 + 1) {
                  g = (vector001.theArray)[index001];
                  Proposition.collectMatchingRuleGoals(((Proposition)(g)), variables, Logic.KWD_TAIL, resultlist);
                }
              }
              return (resultlist);
            }
            else if (testValue000 == Logic.KWD_EXISTS) {
              { Proposition existsbody = ((Proposition)((proposition.arguments.theArray)[0]));

                if (existsbody.kind == Logic.KWD_AND) {
                  { Stella_Object g = null;
                    Vector vector002 = existsbody.arguments;
                    int index002 = 0;
                    int length002 = vector002.length();

                    for (;index002 < length002; index002 = index002 + 1) {
                      g = (vector002.theArray)[index002];
                      Proposition.collectMatchingRuleGoals(((Proposition)(g)), variables, Logic.KWD_TAIL, resultlist);
                    }
                  }
                }
              }
              return (resultlist);
            }
            else {
            }
          }
        }
        else {
        }
      }
      Proposition.collectMatchingRuleGoals(proposition, variables, headortail, resultlist);
      return (resultlist);
    }
  }