code: def verify_path(path, is_collection):
      
      num_elements = len(path)
      if num_elements == 0:
          raise ValueError("Document or collection path cannot be empty")
  
      if is_collection:
          if num_elements % 2 == 0:
              raise ValueError("A collection must have an odd number of path elements")
      else:
          if num_elements % 2 == 1:
              raise ValueError("A document must have an even number of path elements")
  
      for element in path:
          if not isinstance(element, six.string_types):
              msg = BAD_PATH_TEMPLATE.format(element, type(element))
              raise ValueError(msg)
docs: Verifies that a ``path`` has the correct form.
  
      Checks that all of the elements in ``path`` are strings.
  
      Args:
          path (Tuple[str, ...]): The components in a collection or
              document path.
          is_collection (bool): Indicates if the ``path`` represents
              a document or a collection.
  
      Raises:
          ValueError: if
  
              * the ``path`` is empty
              * ``is_collection=True`` and there are an even number of elements
              * ``is_collection=False`` and there are an odd number of elements
              * an element is not a string