@Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    } else if (!(o instanceof SingletonPredictionContext)) {
      return false;
    }

    if (this.hashCode() != o.hashCode()) {
      return false; // can't be same if hash is different
    }

    SingletonPredictionContext s = (SingletonPredictionContext) o;
    return returnState == s.returnState && (parent != null && parent.equals(s.parent));
  }