def merge_adjacent(dom, tag_name):
for node in dom.getElementsByTagName(tag_name):<EOL><INDENT>prev_sib = node.previousSibling<EOL>if prev_sib and prev_sib.nodeName == node.tagName:<EOL><INDENT>for child in list(node.childNodes):<EOL><INDENT>prev_sib.appendChild(child)<EOL><DEDENT>remove_node(node)<EOL><DEDENT><DEDENT>
Merge all adjacent tags with the specified tag name.
Return the number of merges performed.