code: func (itr *combinedIterator) Next() (statedb.QueryResult, error) {
  	if itr.dbItem == nil && itr.updatesItem == nil {
  		logger.Debugf("dbItem and updatesItem both are nil.")
  		return itr.serveEndKeyIfNeeded()
  	}
  	var moveDBItr bool
  	var moveUpdatesItr bool
  	var selectedItem statedb.QueryResult
  	compResult := compareKeys(itr.dbItem, itr.updatesItem)
  	logger.Debugf("compResult=%d", compResult)
  	switch compResult {
  	case -1:
  		// dbItem is smaller
  		selectedItem = itr.dbItem
  		moveDBItr = true
  	case 0:
  		//both items are same so, choose the updatesItem (latest)
  		selectedItem = itr.updatesItem
  		moveUpdatesItr = true
  		moveDBItr = true
  	case 1:
  		// updatesItem is smaller
  		selectedItem = itr.updatesItem
  		moveUpdatesItr = true
  	}
  	var err error
  	if moveDBItr {
  		if itr.dbItem, err = itr.dbItr.Next(); err != nil {
  			return nil, err
  		}
  	}
  
  	if moveUpdatesItr {
  		if itr.updatesItem, err = itr.updatesItr.Next(); err != nil {
  			return nil, err
  		}
  	}
  	if isDelete(selectedItem) {
  		return itr.Next()
  	}
  	logger.Debugf("Returning item=%#v. Next dbItem=%#v, Next updatesItem=%#v", selectedItem, itr.dbItem, itr.updatesItem)
  	return selectedItem, nil
  }
docs: // Next returns the KV from either dbItr or updatesItr that gives the next smaller key
  // If both gives the same keys, then it returns the KV from updatesItr.