parameters: (nest1, nest2, check_types)
docstring: Helper function for `assert_same_structure`.
docstring_summary: Helper function for `assert_same_structure`.
docstring_tokens: Helper function for assert_same_structure .
function: def _recursive_assert_same_structure(nest1, nest2, check_types):
    """Helper function for `assert_same_structure`."""
    is_sequence_nest1 = is_sequence(nest1)
    if is_sequence_nest1 != is_sequence(nest2):
      raise ValueError(
          "The two structures don't have the same nested structure.\n\n"
          "First structure: %s\n\nSecond structure: %s." % (nest1, nest2))
  
    if not is_sequence_nest1:
      return  # finished checking
  
    if check_types:
      type_nest1 = type(nest1)
      type_nest2 = type(nest2)
      if type_nest1 != type_nest2:
        raise TypeError(
            "The two structures don't have the same sequence type. First "
            "structure has type %s, while second structure has type %s."
            % (type_nest1, type_nest2))
  
      if isinstance(nest1, dict):
        keys1 = set(_six.iterkeys(nest1))
        keys2 = set(_six.iterkeys(nest2))
        if keys1 != keys2:
          raise ValueError(
              "The two dictionaries don't have the same set of keys. First "
              "structure has keys {}, while second structure has keys {}."
              .format(keys1, keys2))
  
    nest1_as_sequence = [n for n in _yield_value(nest1)]
    nest2_as_sequence = [n for n in _yield_value(nest2)]
    for n1, n2 in zip(nest1_as_sequence, nest2_as_sequence):
      _recursive_assert_same_structure(n1, n2, check_types)
function_tokens: def _recursive_assert_same_structure ( nest1 , nest2 , check_types ) : is_sequence_nest1 = is_sequence ( nest1 ) if is_sequence_nest1 != is_sequence ( nest2 ) : raise ValueError ( "The two structures don't have the same nested structure.\n\n" "First structure: %s\n\nSecond structure: %s." % ( nest1 , nest2 ) ) if not is_sequence_nest1 : return # finished checking if check_types : type_nest1 = type ( nest1 ) type_nest2 = type ( nest2 ) if type_nest1 != type_nest2 : raise TypeError ( "The two structures don't have the same sequence type. First " "structure has type %s, while second structure has type %s." % ( type_nest1 , type_nest2 ) ) if isinstance ( nest1 , dict ) : keys1 = set ( _six . iterkeys ( nest1 ) ) keys2 = set ( _six . iterkeys ( nest2 ) ) if keys1 != keys2 : raise ValueError ( "The two dictionaries don't have the same set of keys. First " "structure has keys {}, while second structure has keys {}." . format ( keys1 , keys2 ) ) nest1_as_sequence = [ n for n in _yield_value ( nest1 ) ] nest2_as_sequence = [ n for n in _yield_value ( nest2 ) ] for n1 , n2 in zip ( nest1_as_sequence , nest2_as_sequence ) : _recursive_assert_same_structure ( n1 , n2 , check_types )