docs: function (
      elementMatcher, options) {
    options = options || {};
    return function (branches) {
      var expanded = branches;
      if (!options.dontExpandLeafArrays) {
        expanded = expandArraysInBranches(
          branches, options.dontIncludeLeafArrays);
      }
      var ret = {};
      ret.result = _.any(expanded, function (element) {
        var matched = elementMatcher(element.value);
  
        // Special case for $elemMatch: it means "true, and use this as an array
        // index if I didn't already have one".
        if (typeof matched === 'number') {
          // XXX This code dates from when we only stored a single array index
          // (for the outermost array). Should we be also including deeper array
          // indices from the $elemMatch match?
          if (!element.arrayIndices)
            element.arrayIndices = [matched];
          matched = true;
        }
  
        // If some element matched, and it's tagged with array indices, include
        // those indices in our result object.
        if (matched && element.arrayIndices)
          ret.arrayIndices = element.arrayIndices;
  
        return matched;
      });
      return ret;
    };
  }