static A msOneOf(MultiSet ms) { int total = ms.size(); if (total == 0) ret null; int n = random(total); for (Map.Entry entry : ms.map.entrySet()) { n -= entry.getValue(); if (n < 0) return entry.getKey(); } ret null; }