In your XSL, if you need to test to see if the next element is named the same as the current one you can use the following piece of code to get the result using a combination of XPATH axes and the name() function.
<xsl:if test="name(./following-sibling::*) = name(.)"> <!-- Do something --> </xsl:if>
This little test got me stumped for a good half an hour. Hopefully this helps some other people.