code: func (c *cursor) chooseIterator(forwards bool) bool {
  	// Skip any keys at the current database iterator position that are
  	// being updated by the transaction.
  	c.skipPendingUpdates(forwards)
  
  	// When both iterators are exhausted, the cursor is exhausted too.
  	if !c.dbIter.Valid() && !c.pendingIter.Valid() {
  		c.currentIter = nil
  		return false
  	}
  
  	// Choose the database iterator when the pending keys iterator is
  	// exhausted.
  	if !c.pendingIter.Valid() {
  		c.currentIter = c.dbIter
  		return true
  	}
  
  	// Choose the pending keys iterator when the database iterator is
  	// exhausted.
  	if !c.dbIter.Valid() {
  		c.currentIter = c.pendingIter
  		return true
  	}
  
  	// Both iterators are valid, so choose the iterator with either the
  	// smaller or larger key depending on the forwards flag.
  	compare := bytes.Compare(c.dbIter.Key(), c.pendingIter.Key())
  	if (forwards && compare > 0) || (!forwards && compare < 0) {
  		c.currentIter = c.pendingIter
  	} else {
  		c.currentIter = c.dbIter
  	}
  	return true
  }
docs: // chooseIterator first skips any entries in the database iterator that are
  // being updated by the transaction and sets the current iterator to the
  // appropriate iterator depending on their validity and the order they compare
  // in while taking into account the direction flag.  When the cursor is being
  // moved forwards and both iterators are valid, the iterator with the smaller
  // key is chosen and vice versa when the cursor is being moved backwards.