docs: def validate_level_indexes(num_levels, v_level_indexes, h_level_indexes):
      """Ensure that v_level_indexes and h_level_indexes are consistent.
  
      Args:
          num_levels: The number of levels of keys in the data structure being tabulated.
          v_level_indexes: A sequence of level indexes between zero and num_levels for
              the vertical axis, or None.
          h_level_indexes: A sequence of level indexes between zero and num_levels for for
              the horizontal axis, or None.
  
      Returns:
          A 2-tuple containing v_level_indexes and h_level_indexes sequences.
  
      Raises:
          ValueError: If v_level_indexes contains duplicate values.
          ValueError: If h_level_indexes contains duplicate values.
          ValueError: If v_level_indexes contains out of range values.
          ValueError: If h_level_indexes contains out of range values.
          ValueError: If taken together v_level_indexes and h_level_indexes
              do not include all levels from zero to up to, but not including
              num_levels.
          ValueError: If v_level_indexes and h_level_indexes have items in
              common.
      """
      if num_levels < 1:
          raise ValueError("num_levels {} is less than one".format(num_levels))
  
      all_levels = SortedFrozenSet(range(num_levels))
  
      if (h_level_indexes is None) and (v_level_indexes is None):
          v_level_indexes = range(0, num_levels, 2)
          h_level_indexes = range(1, num_levels, 2)
  
      h_level_set = SortedFrozenSet(h_level_indexes)
      v_level_set = SortedFrozenSet(v_level_indexes)
  
      if h_level_indexes is None:
          h_level_indexes = all_levels - v_level_set
      if v_level_indexes is None:
          v_level_indexes = all_levels - h_level_set
  
      if len(h_level_indexes) != len(h_level_set):
          raise ValueError("h_level_indexes contains duplicate values")
      if h_level_set and ((h_level_set[0] < 0) or (h_level_set[-1] >= num_levels)):
          raise ValueError("h_level_indexes contains out of range values")
      if len(v_level_indexes) != len(v_level_set):
          raise ValueError("v_level_indexes contains duplicate values")
      if v_level_set and ((v_level_set[0] < 0) or (v_level_set[-1] >= num_levels)):
          raise ValueError("v_level_indexes contains out of range values")
  
      unmentioned_levels = all_levels - v_level_set - h_level_set
      if len(unmentioned_levels) > 0:
          raise ValueError(
              "v_level_indexes and h_level_indexes do not together include levels {}".format(
                  ", ".join(map(str, unmentioned_levels))
              )
          )
      if not h_level_set.isdisjoint(v_level_set):
          raise ValueError("h_level_indexes and v_level_indexes are not disjoint")
      v_level_indexes = list(v_level_indexes)
      h_level_indexes = list(h_level_indexes)
      return v_level_indexes, h_level_indexes