title: java.util.NoSuchElementException - on iterating over sorted treemap
body: <p>I'm looping over my program, and for no certain reasons I've got the following error</p>
  
  <pre><code>Exception in thread "main" java.util.NoSuchElementException
      at java.util.TreeMap$PrivateEntryIterator.nextEntry(Unknown Source)
      at java.util.TreeMap$KeyIterator.next(Unknown Source)
      at EloRating.setNewSeason(EloRating.java:242)
  </code></pre>
  
  <p>This error points to the iterator loop.</p>
  
  <pre><code>TreeMap&lt;String,Double&gt; treeMap = new TreeMap&lt;String,Double&gt;();
                                      for (Entry&lt;String, Double&gt; team : teamsIntersection.entrySet()) {
                                          treeMap.put(team.getKey(), listTeams.get(team.getKey()).getRating());
                                          }
  
                                      SortedSet&lt;Entry&lt;String, Double&gt;&gt; listSorted = entriesSortedByValues(treeMap);
                                      Iterator&lt;Entry&lt;String, Double&gt;&gt; iter = listSorted.iterator();
  
                                      int stop = (amountOfIntersectTeams+1)/2;
                                      for(int i = 0; i &lt; (stop-1); i++){
                          -----------&gt;   iter.next();
                                      }
                                      double median = iter.next().getValue();
  </code></pre>
  
  <p>If I execute the program once, nothing special happens. But for some benchmark reasons I've to loop over the program 25.000 times with some slightly adjusted parameters.
  And when I try to start the program again with the parameters from after an error, it will go further.  [At the moment of this error,  iterator contained 10 values]</p>
  
  <h2>Goal</h2>
  
  <p>I want to have the upper median on the values of the Hashmap teamsIntersection.
  e.g.  a-3 b-1  c-2  d-2   e-5 f-4 then I want the value of 3 back from a</p>
  
  <h2>entriesSortedByValue</h2>
  
  <pre><code>static &lt;K,V extends Comparable&lt;? super V&gt;&gt;
      SortedSet&lt;Map.Entry&lt;K,V&gt;&gt; entriesSortedByValues(Map&lt;K,V&gt; map) {
          SortedSet&lt;Map.Entry&lt;K,V&gt;&gt; sortedEntries = new TreeSet&lt;Map.Entry&lt;K,V&gt;&gt;(
              new Comparator&lt;Map.Entry&lt;K,V&gt;&gt;() {
                  @Override public int compare(Map.Entry&lt;K,V&gt; e1, Map.Entry&lt;K,V&gt; e2) {
                      return e1.getValue().compareTo(e2.getValue());
                  }
              }
          );
          sortedEntries.addAll(map.entrySet());
          return sortedEntries;
      }
  </code></pre>