Rewrite of the whole class. It now supports nested tags of the same type.