docs: function walkIterator(query, parent, state) {
    var nodes = parent.children
    var typeIndex = state.index ? createTypeIndex() : null
    var delayed = []
  
    return {
      prefillTypeIndex: rangeDefaults(prefillTypeIndex),
      each: rangeDefaults(each),
      done: done
    }
  
    function done() {
      var length = delayed.length
      var index = -1
  
      while (++index < length) {
        delayed[index]()
  
        if (state.one && state.found) {
          break
        }
      }
  
      return this
    }
  
    function prefillTypeIndex(start, end) {
      if (typeIndex) {
        while (start < end) {
          typeIndex(nodes[start])
          start++
        }
      }
  
      return this
    }
  
    function each(start, end) {
      var child = nodes[start]
      var index
      var elementIndex
  
      if (start >= end) {
        return this
      }
  
      if (typeIndex) {
        elementIndex = typeIndex.elements
        index = typeIndex(child)
        delayed.push(delay)
      } else {
        pushNode()
      }
  
      /* Stop if we’re looking for one node and it’s already found. */
      if (state.one && state.found) {
        return this
      }
  
      return each.call(this, start + 1, end)
  
      function delay() {
        state.typeIndex = index
        state.elementIndex = elementIndex
        state.typeCount = typeIndex.count(child)
        state.elementCount = typeIndex.elements
        pushNode()
      }
  
      function pushNode() {
        var exit = enter(state, child)
        state.iterator(query, child, start, parent, state)
        exit()
      }
    }
  
    function rangeDefaults(iterator) {
      return rangeDefault
  
      function rangeDefault(start, end) {
        if (start === null || start === undefined || start < 0) {
          start = 0
        }
  
        if (end === null || end === undefined || end > nodes.length) {
          end = nodes.length
        }
  
        return iterator.call(this, start, end)
      }
    }
  }