code: function groupNestedPredicates(_nestedPredicates) {
      let maxDepth = 0;
      const nestedPredicateObj = {};
      const nestedPredicateParts = _.map(_nestedPredicates, (predicateArr) => {
        const predicate = predicateArr[0];
        const retVal = predicate.split('.');
        nestedPredicateObj[predicate] = predicateArr[1];
        retVal.length > maxDepth && (maxDepth = retVal.length);
        return retVal;
      });
      const groups = {};
  
      for (let i = 0; i < maxDepth; i++) {
        groups[i] = _.groupBy(nestedPredicateParts, (predicateParts) => {
          let retval = '';
          for (let j = 0; j < i + 1; j++) {
            retval += (predicateParts[j] ? `${predicateParts[j]}.` : '');
          }
          return retval.substr(0, retval.length - 1);
        });
      }
  
      const completed = {};
      const levels = {};
      const paths = {};
  
      // Simplifies the grouping
      for (let i = maxDepth - 1; i >= 0; i--) {
        _.each(groups[i], (values, key) => {
          _.each(values, (value) => {
            const strKey = value.join('.');
            if (!completed[strKey] && values.length > 1) {
              (!levels[i] && (levels[i] = []));
              levels[i].push(strKey);
              (completed[strKey] = true);
              paths[i] = key;
            }
            if (!completed[strKey] && i < 1) {
              (!levels[i] && (levels[i] = []));
              levels[i].push(strKey);
              (completed[strKey] = true);
              paths[i] = key;
            }
          });
        });
      }
  
      return { groups: levels, paths, nestedPredicateObj };
    }
docs: Groups predicates at their lowest match level to simplify creating nested queries