Smack/MUCUserProvider.java at master · igniterealtime/Smack · GitHub
Basically the condition to determine if you are at the end tag of a element should not be
parser.getEventType == END_TAG && parser.getName().equals("foo")
but
parser.getEventType == END_TAG && parser.getDepth() == startTagDepth
otherwise you could end up considering to be at the end of a tag when it comes to nested elements with the same name. This has hit Smack with the introduction of carbons, where a message can be contained within a message.