An alternative way that works with a TreeMap but will destroys the map at the end of the iteration.  Not a good solution but keeping track of this here.
var size = populatedMap.size();
for (var i = 0; i < size; i++) {
   var entry = populatedMap.firstEntry();
   populatedMap.remove(entry.getKey());