* @param localP
   * @return Iterator
   */
  public static Iterator allNamedTerms(Module module, boolean localP) {
    if (localP) {
      { AllPurposeIterator self000 = AllPurposeIterator.newAllPurposeIterator();

        self000.iteratorNestedIterator = Logic.locallyConceivedInstances(module).allocateIterator();
        self000.iteratorNextCode = Native.find_java_method("edu.isi.stella.AllPurposeIterator", "filteredNestedIteratorNextP", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.AllPurposeIterator")});
        self000.iteratorFilterCode = Native.find_java_method("edu.isi.powerloom.logic.Logic", "namedTermP", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.Stella_Object"), Native.find_java_class("edu.isi.stella.AllPurposeIterator")});
        { AllPurposeIterator value000 = self000;

          return (value000);
        }
      }
    }
    else {
      { Iterator iterator1 = Logic.allNamedTerms(module, true);
        Cons iteratorlist = Stella.NIL;

        { Context renamed_Super = null;
          Cons iter000 = module.allSuperContexts;
          Cons collect000 = null;

          for (;!(iter000 == Stella.NIL); iter000 = iter000.rest) {
            renamed_Super = ((Context)(iter000.value));
            if (collect000 == null) {
              {
                collect000 = Cons.cons(Logic.allNamedTerms(((Module)(renamed_Super)), true), Stella.NIL);
                if (iteratorlist == Stella.NIL) {
                  iteratorlist = collect000;
                }
                else {
                  Cons.addConsToEndOfConsList(iteratorlist, collect000);
                }
              }
            }
            else {
              {
                collect000.rest = Cons.cons(Logic.allNamedTerms(((Module)(renamed_Super)), true), Stella.NIL);
                collect000 = collect000.rest;
              }
            }
          }
        }
        if (iteratorlist == Stella.NIL) {
          return (iterator1);
        }
        else {
          { AllPurposeIterator self001 = AllPurposeIterator.newAllPurposeIterator();

            self001.iteratorNestedIterator = iterator1;
            self001.iteratorConsList = iteratorlist;
            self001.iteratorNextCode = Native.find_java_method("edu.isi.stella.AllPurposeIterator", "filteredConcatenatedIteratorNextP", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.AllPurposeIterator")});
            { AllPurposeIterator value001 = self001;

              return (value001);
            }
          }
        }
      }
    }
  }