code: function mergeAndedSelectors(selectors) {
  
    // sort to ensure that e.g. if the user specified
    // $and: [{$gt: 'a'}, {$gt: 'b'}], then it's collapsed into
    // just {$gt: 'b'}
    var res = {};
  
    selectors.forEach(function (selector) {
      Object.keys(selector).forEach(function (field) {
        var matcher = selector[field];
        if (typeof matcher !== 'object') {
          matcher = {$eq: matcher};
        }
  
        if (isCombinationalField(field)) {
          if (matcher instanceof Array) {
            res[field] = matcher.map(function (m) {
              return mergeAndedSelectors([m]);
            });
          } else {
            res[field] = mergeAndedSelectors([matcher]);
          }
        } else {
          var fieldMatchers = res[field] = res[field] || {};
          Object.keys(matcher).forEach(function (operator) {
            var value = matcher[operator];
  
            if (operator === '$gt' || operator === '$gte') {
              return mergeGtGte(operator, value, fieldMatchers);
            } else if (operator === '$lt' || operator === '$lte') {
              return mergeLtLte(operator, value, fieldMatchers);
            } else if (operator === '$ne') {
              return mergeNe(value, fieldMatchers);
            } else if (operator === '$eq') {
              return mergeEq(value, fieldMatchers);
            }
            fieldMatchers[operator] = value;
          });
        }
      });
    });
  
    return res;
  }
docs: flatten an array of selectors joined by an $and operator