if (event.isStartElement()) {
StartElement start = event.asStartElement();
if (isRemovable(start)) {
while (reader.hasNext()) {
XMLEvent next = reader.nextEvent();
if (next.isEndElement() && next.asEndElement().getName().equals(start.getName()))
continue EventLoop;
}
// If this is reached, we finished the document before the tag ended
throw new RuntimeException(String.format("End of file was reached before %s closing tag was found.",
start.getName()));