public static Cons removeShadowedSymbols(Cons visiblesymbols) {
    if (visiblesymbols.rest == Stella.NIL) {
      return (visiblesymbols);
    }
    { Cons shadowingmodules = Stella.NIL;

      { GeneralizedSymbol symbol = null;
        Cons iter000 = visiblesymbols;
        Cons collect000 = null;

        for (;!(iter000 == Stella.NIL); iter000 = iter000.rest) {
          symbol = ((GeneralizedSymbol)(iter000.value));
          if (GeneralizedSymbol.shadowedSymbolP(symbol)) {
            if (collect000 == null) {
              {
                collect000 = Cons.cons(((Module)(symbol.homeContext)), Stella.NIL);
                if (shadowingmodules == Stella.NIL) {
                  shadowingmodules = collect000;
                }
                else {
                  Cons.addConsToEndOfConsList(shadowingmodules, collect000);
                }
              }
            }
            else {
              {
                collect000.rest = Cons.cons(((Module)(symbol.homeContext)), Stella.NIL);
                collect000 = collect000.rest;
              }
            }
          }
        }
      }
      if (!(shadowingmodules == Stella.NIL)) {
        { Cons unshadowedsymbols = Stella.NIL;

          { GeneralizedSymbol symbol = null;
            Cons iter001 = visiblesymbols;
            Cons collect001 = null;

            for (;!(iter001 == Stella.NIL); iter001 = iter001.rest) {
              symbol = ((GeneralizedSymbol)(iter001.value));
              { boolean testValue000 = false;

                { boolean foundP000 = false;

                  { Module module = null;
                    Cons iter002 = shadowingmodules;

                    loop002 : for (;!(iter002 == Stella.NIL); iter002 = iter002.rest) {
                      module = ((Module)(iter002.value));
                      if ((!(module == ((Module)(symbol.homeContext)))) &&
                          Context.visibleFromP(((Module)(symbol.homeContext)), module)) {
                        foundP000 = true;
                        break loop002;
                      }
                    }
                  }
                  testValue000 = foundP000;
                }
                testValue000 = !testValue000;
                if (testValue000) {
                  if (collect001 == null) {
                    {
                      collect001 = Cons.cons(symbol, Stella.NIL);
                      if (unshadowedsymbols == Stella.NIL) {
                        unshadowedsymbols = collect001;
                      }
                      else {
                        Cons.addConsToEndOfConsList(unshadowedsymbols, collect001);
                      }
                    }
                  }
                  else {
                    {
                      collect001.rest = Cons.cons(symbol, Stella.NIL);
                      collect001 = collect001.rest;
                    }
                  }
                }
              }
            }
          }
          visiblesymbols = unshadowedsymbols;
        }
      }
      return (visiblesymbols);
    }
  }