code: func mergeSeries(in []models.Series) []models.Series {
  	type segment struct {
  		target string
  		query  string
  		from   uint32
  		to     uint32
  		con    consolidation.Consolidator
  	}
  	seriesByTarget := make(map[segment][]models.Series)
  	for _, series := range in {
  		s := segment{
  			series.Target,
  			series.QueryPatt,
  			series.QueryFrom,
  			series.QueryTo,
  			series.Consolidator,
  		}
  		seriesByTarget[s] = append(seriesByTarget[s], series)
  	}
  	merged := make([]models.Series, len(seriesByTarget))
  	i := 0
  	for _, series := range seriesByTarget {
  		if len(series) == 1 {
  			merged[i] = series[0]
  		} else {
  			//we use the first series in the list as our result.  We check over every
  			// point and if it is null, we then check the other series for a non null
  			// value to use instead.
  			log.Debugf("DP mergeSeries: %s has multiple series.", series[0].Target)
  			for i := range series[0].Datapoints {
  				for j := 0; j < len(series); j++ {
  					if !math.IsNaN(series[j].Datapoints[i].Val) {
  						series[0].Datapoints[i].Val = series[j].Datapoints[i].Val
  						break
  					}
  				}
  			}
  			merged[i] = series[0]
  		}
  		i++
  	}
  	return merged
  }
docs: // check for duplicate series names for the same query. If found merge the results.