The logic here changed slightly in the refactored version in `_getNextMatch()` so we could support a `wrap` parameter.