code: private void mergeExternSymbolsDuplicatedOnWindow() {
      // To find duplicated symbols we rely on the fact that duplicated symbol share the same
      // source position as original symbol and going to use filename => sourcePosition => symbol
      // table.
      Table<String, Integer, Symbol> externSymbols = HashBasedTable.create();
      for (Symbol symbol : ImmutableList.copyOf(symbols.values())) {
        if (symbol.getDeclarationNode() == null
            || symbol.getDeclarationNode().getStaticSourceFile() == null
            || !symbol.getDeclarationNode().getStaticSourceFile().isExtern()) {
          continue;
        }
        String sourceFile = symbol.getSourceFileName();
        int position = symbol.getDeclarationNode().getSourcePosition();
        if (!externSymbols.contains(sourceFile, position)) {
          externSymbols.put(sourceFile, position, symbol);
          continue;
        }
        Symbol existingSymbol = externSymbols.get(sourceFile, position);
        // Consider 2 possibilies: either symbol or existingSymbol might be the generated symbol we
        // are looking for.
        if (isSymbolDuplicatedExternOnWindow(existingSymbol)) {
          mergeSymbol(existingSymbol, symbol);
          externSymbols.put(sourceFile, position, symbol);
        } else if (isSymbolDuplicatedExternOnWindow(symbol)) {
          mergeSymbol(symbol, existingSymbol);
        }
      }
    }
docs: DeclaredGLobalExternsOnWindow.java pass duplicates all global variables so that:
  
  <pre>
  var foo;
  </pre>
  
  becomes
  
  <pre>
  var foo;
  window.foo;
  </pre>
  
  This function finds all such cases and merges window.foo symbol back to foo. It changes
  window.foo references to point to foo symbol.