function mergeChildMatches(childMatches) {
    if (childMatches.length === 0) {
      return childMatches;
    }

    var sets = childMatches.reduce(combineChildMatches);
    var uniqueSets = [];
    var unique = {};

    for (var i = 0; i < sets.length; i++) {
      var s = JSON.stringify(sets[i]);

      if (!unique[s]) {
        unique[s] = true;
        uniqueSets.push(sets[i]);
      }
    }

    return uniqueSets;
  }
Combine multiple lists of matches by applying mergeMatch to the cartesian product of two lists of matches.
Each list represents matches found in one child of a node.
Returns a list of unique matches.