Source
def select_next_sibling(self):
ret = pyNodeList()
n = self.next_all()
if isinstance(n, pyNode):
tmp = pyNodeList()
tmp.append(n)
n = tmp
if isinstance(n, pyNodeList) and len(n) != 0:
for elem in n:
if elem.has_child():
for child in elem.children():
ret.append(child)
descendants = child.descendant()
if isinstance(descendants, pyNode):
ret.append(descendants)
elif isinstance(descendants, pyNodeList):
ret.extend(descendants)
if len(ret) == 1: return ret[0]
else: return ret