Source
def select_only_of_type(self):
ret = pyNodeList()
for node in self:
if node.has_parent():
tag_name = node.name()
duplicated = False
for ch in node.parent().children():
if ch != node and tag_name == ch.name():
duplicated = True
break
if not duplicated: ret.append(node)
if len(ret) == 1: return ret[0]
else: return ret