docs: def split(cls,
              n,
              contiguous,
              can_query=itertools.chain(itertools.repeat(True, 50),
                                        itertools.repeat(False)).next,
              _app=None):
      # pylint: disable=g-doc-args
      """Splits the complete NamespaceRange into n equally-sized NamespaceRanges.
  
      Args:
        n: The maximum number of NamespaceRanges to return. Fewer than n
            namespaces may be returned.
        contiguous: If True then the returned NamespaceRanges will cover the
            entire space of possible namespaces (i.e. from MIN_NAMESPACE to
            MAX_NAMESPACE) without gaps. If False then the returned
            NamespaceRanges may exclude namespaces that don't appear in the
            datastore.
        can_query: A function that returns True if split() can query the datastore
            to generate more fair namespace range splits, and False otherwise.
            If not set then split() is allowed to make 50 datastore queries.
  
      Returns:
        A list of at most n NamespaceRanges representing a near-equal distribution
        of actual existant datastore namespaces. The returned list will be sorted
        lexographically.
  
      Raises:
        ValueError: if n is < 1.
      """
      if n < 1:
        raise ValueError('n must be >= 1')
  
      ranges = None
      if can_query():
        if not contiguous:
          ns_keys = get_namespace_keys(_app, n + 1)
          if not ns_keys:
            return []
          else:
            if len(ns_keys) <= n:
              # If you have less actual namespaces than number of NamespaceRanges
              # to return, then just return the list of those namespaces.
              ns_range = []
              for ns_key in ns_keys:
                ns_range.append(NamespaceRange(ns_key.name() or '',
                                               ns_key.name() or '',
                                               _app=_app))
              return sorted(ns_range,
                            key=lambda ns_range: ns_range.namespace_start)
            # Use the first key and save the initial normalized_start() call.
            ranges = [NamespaceRange(ns_keys[0].name() or '', _app=_app)]
        else:
          ns_range = NamespaceRange(_app=_app).normalized_start()
          if ns_range is None:
            return [NamespaceRange(_app=_app)]
          ranges = [ns_range]
      else:
        ranges = [NamespaceRange(_app=_app)]
  
      singles = []
      while ranges and (len(ranges) + len(singles)) < n:
        namespace_range = ranges.pop(0)
        if namespace_range.is_single_namespace:
          singles.append(namespace_range)
        else:
          left, right = namespace_range.split_range()
          if can_query():
            right = right.normalized_start()
          if right is not None:
            ranges.append(right)
          ranges.append(left)
      ns_ranges = sorted(singles + ranges,
                         key=lambda ns_range: ns_range.namespace_start)
  
      if contiguous:
        if not ns_ranges:
          # This condition is possible if every namespace was deleted after the
          # first call to ns_range.normalized_start().
          return [NamespaceRange(_app=_app)]
  
        continuous_ns_ranges = []
        for i in range(len(ns_ranges)):
          if i == 0:
            namespace_start = MIN_NAMESPACE
          else:
            namespace_start = ns_ranges[i].namespace_start
  
          if i == len(ns_ranges) - 1:
            namespace_end = MAX_NAMESPACE
          else:
            namespace_end = _ord_to_namespace(
                _namespace_to_ord(ns_ranges[i+1].namespace_start) - 1)
  
          continuous_ns_ranges.append(NamespaceRange(namespace_start,
                                                     namespace_end,
                                                     _app=_app))
        return continuous_ns_ranges
      else:
        return ns_ranges