public boolean addState(Gameboy gb, ListState s) {
    int stepCount = s == null ? 0 : s.stepCount;
    if (stepCount > MAX_STEP_COUNT)
      return false;
    if (!stateMap.isEmpty() && stateMap.firstKey() + MAX_STEP_COUNT_DIFFERENCE < stepCount)
      return false;
    if(!stateMap.containsKey(stepCount))
      stateMap.put(stepCount, new ArrayList<ListState>());
    List<ListState> subMap = stateMap.get(stepCount);

    subMap.add(s);
    if (in != null)
      pruneState(gb, in);
    prune();
    return true;
  }