title: Trimming a TreeMap to n entries
body: <p>I have a sorted TreeMap, and I want to remove all but the first 10 elements. What is a way to do this? I have considered removing elements from the end of the map while the map size is greater than 10, but I don't know how to do that. Could I convert to a List and then back?</p>
  
  <p>Thanks</p>