code: private S mostLikelyState() {
          // Otherwise an HMM break would have occurred and message would be null.
          assert !message.isEmpty();
  
          S result = null;
          double maxLogProbability = Double.NEGATIVE_INFINITY;
          for (Map.Entry<S, Double> entry : message.entrySet()) {
              if (entry.getValue() > maxLogProbability) {
                  result = entry.getKey();
                  maxLogProbability = entry.getValue();
              }
          }
  
          assert result != null; // Otherwise an HMM break would have occurred.
          return result;
      }
docs: Retrieves the first state of the current forward message with maximum probability.