def _check_symbols_eq_and_maybe_increment(token_a, token_b, state, search_stack,
                                          sub_complete):
  """Returns new states if token_a and token_b are equal."""

  # First, check if symbols are exactly equal.
  if _symbols_eq(state, token_a, token_b):
    new_state = SearchState(
        tuple_a_idx=state.tuple_a_idx + 1,
        tuple_b_idx=state.tuple_b_idx + 1,
        sub_complete=sub_complete,
        sub_lhs=state.sub_lhs,
        sub_rhs=state.sub_rhs,
        nt_subs=state.nt_subs)
    search_stack.append(new_state)

  # Second, check if symbols vary only in non-terminal index.
  nt_sub = _find_nt_sub(state, token_a, token_b)
  if nt_sub:
    new_nt_subs = state.nt_subs.copy()
    new_nt_subs[nt_sub[0]] = nt_sub[1]
    new_state = SearchState(
        tuple_a_idx=state.tuple_a_idx + 1,
        tuple_b_idx=state.tuple_b_idx + 1,
        sub_complete=sub_complete,
        sub_lhs=state.sub_lhs,
        sub_rhs=state.sub_rhs,
        nt_subs=new_nt_subs)
    search_stack.append(new_state)
Returns new states if token_a and token_b are equal.
language/compgen/csl/induction/unification_utils.py