code: function PDFFindController_prepareMatches(matchesWithLength, matches, matchesLength) {
              function isSubTerm(matchesWithLength, currentIndex) {
                var currentElem, prevElem, nextElem;
                currentElem = matchesWithLength[currentIndex];
                nextElem = matchesWithLength[currentIndex + 1];
                // checking for cases like "TAMEd TAME"
                if (currentIndex < matchesWithLength.length - 1 && currentElem.match === nextElem.match) {
                  currentElem.skipped = true;
                  return true;
                }
                // checking for cases like "thIS IS"
                for (var i = currentIndex - 1; i >= 0; i--) {
                  prevElem = matchesWithLength[i];
                  if (prevElem.skipped) {
                    continue;
                  }
                  if (prevElem.match + prevElem.matchLength < currentElem.match) {
                    break;
                  }
                  if (prevElem.match + prevElem.matchLength >= currentElem.match + currentElem.matchLength) {
                    currentElem.skipped = true;
                    return true;
                  }
                }
                return false;
              }
              var i, len;
              // Sorting array of objects { match: <match>, matchLength: <matchLength> }
              // in increasing index first and then the lengths.
              matchesWithLength.sort(function (a, b) {
                return a.match === b.match ? a.matchLength - b.matchLength : a.match - b.match;
              });
              for (i = 0, len = matchesWithLength.length; i < len; i++) {
                if (isSubTerm(matchesWithLength, i)) {
                  continue;
                }
                matches.push(matchesWithLength[i].match);
                matchesLength.push(matchesWithLength[i].matchLength);
              }
            }
docs: Helper for multiple search - fills matchesWithLength array and takes into account cases when one search term include another search term (for example, "tamed tame" or "this is"). Looking for intersecting terms in the 'matches' and leave elements with a longer match-length.