it'll be much better if we give the stream object a function like:
```
findNext: function(pattern, groupNumber) {
  // search this.stream for a regex pattern match after the current
  // this.pos position, making sure to cache state prior to search,
  // and restore state after searching, before returning.
  return captureGroups[groupNumber];
}
```
and then call it with something like:
```
function isNextTagParent(stream, parentTagName)
  return stream.findNext(/<\/([\w\-]+)\s*>/, 1) === parentTagName;
}
```
That way the stream stays responsible for stream operations, and the consuming code simply has a single function call.