scope lcStream_itemCounts. // counts how often an item actually appears in the text static MultiSet lcStream_itemCounts(LCStreamingCompressor comp) { new MultiSet ms; for (int idx : comp.chain.toList()) recurse(ms, comp, idx, 1); ret ms; } svoid #recurse(LCStreamingCompressor comp, MultiSet ms, int idx, int n) { ms.add(idx, n); IntPair p = comp.getPair(idx); if (p != null) { recurse(comp, ms, p.a, n); recurse(comp, ms, p.b, n); } } end scope