/** Helper function to reverse locate the key. */
  protected String getKey(IGraphEntity value) {
    if (value instanceof TicTacToeState) {
      TicTacToeState state = (TicTacToeState) value;
      String id = "s" + state.counter();
      return id;
    }

    if (value instanceof AlphaBetaDebugNode) {
      AlphaBetaDebugNode state = (AlphaBetaDebugNode) value;
      String id = "a" + state.counter();
      return id;
    }
    return super.getKey(value);
  }
  /**
   * Mark node as being visited.
   *
   * <p>Special case for our purposes is to use generated state number from search process. While
   * this is a bit of a "hack", it makes it easy to generate effective visualizations of the search.
   */
  public void visitNode(IGraphEntity n) {
    if (n instanceof TicTacToeState) {
      TicTacToeState state = (TicTacToeState) n;
      String id = "s" + state.counter();
      nodes.put(id, state.copy());
      return;
    }

    if (n instanceof AlphaBetaDebugNode) {
      AlphaBetaDebugNode node = (AlphaBetaDebugNode) n;
      String id = "a" + node.counter();
      nodes.put(id, node.copy());
      return;
    }

    super.visitNode(n);
  }