public static List filteredAllFactsOfN(int n, Cons seedrefs, java.lang.reflect.Method filter) {
    { HashTable visited = HashTable.newHashTable();
      HashTable facts = HashTable.newHashTable();
      List factlist = List.newList();
      List seeds = List.newList();
      List newseeds = List.newList();
      Stella_Object instance = null;

      { Stella_Object seedref = null;
        Cons iter000 = seedrefs;

        for (;!(iter000 == Stella.NIL); iter000 = iter000.rest) {
          seedref = iter000.value;
          instance = Logic.coerceToInstance(seedref, null);
          if (instance != null) {
            seeds.insertNew(instance);
          }
        }
      }
      { int i = Stella.NULL_INTEGER;
        int iter001 = 0;
        int upperBound000 = ((n != Stella.NULL_INTEGER) ? n : 0);
        boolean unboundedP000 = upperBound000 == Stella.NULL_INTEGER;

        for (;unboundedP000 ||
                  (iter001 <= upperBound000); iter001 = iter001 + 1) {
          i = iter001;
          i = i;
          { Stella_Object seed = null;
            Cons iter002 = seeds.theConsList;

            for (;!(iter002 == Stella.NIL); iter002 = iter002.rest) {
              seed = iter002.value;
              visited.insertAt(seed, seed);
            }
          }
          { Stella_Object seed = null;
            Cons iter003 = seeds.theConsList;

            for (;!(iter003 == Stella.NIL); iter003 = iter003.rest) {
              seed = iter003.value;
              { Proposition prop = null;
                Cons iter004 = Logic.allFactsOfInstance(seed, false, true).theConsList;

                loop004 : for (;!(iter004 == Stella.NIL); iter004 = iter004.rest) {
                  prop = ((Proposition)(iter004.value));
                  if (((Proposition)(facts.lookup(prop))) != null) {
                    continue loop004;
                  }
                  { Cons filteroutput = ((Cons)(edu.isi.stella.javalib.Native.funcall(filter, null, new java.lang.Object [] {prop})));
                    Cons factprops = ((Cons)(filteroutput.value));
                    Cons propseeds = ((Cons)(filteroutput.rest.value));

                    { Proposition factprop = null;
                      Cons iter005 = factprops;

                      for (;!(iter005 == Stella.NIL); iter005 = iter005.rest) {
                        factprop = ((Proposition)(iter005.value));
                        facts.insertAt(factprop, factprop);
                        factlist.insert(factprop);
                      }
                    }
                    { Stella_Object arg = null;
                      Cons iter006 = propseeds;

                      for (;!(iter006 == Stella.NIL); iter006 = iter006.rest) {
                        arg = iter006.value;
                        if (visited.lookup(arg) == null) {
                          newseeds.insertNew(arg);
                        }
                      }
                    }
                  }
                }
              }
            }
          }
          seeds = newseeds;
          newseeds = List.newList();
        }
      }
      return (factlist.reverse());
    }
  }