code: private Long next(long t) {
          SortedMap<Long, int[]> x = data.tailMap(t + 1);
          return x.isEmpty() ? null : x.firstKey();
      }
docs: Finds smallest t' > t where q(t')!=q(t)
  
  If there's no such t' this method returns null.