def _children_of_type(self, atype: Type = Node, recurse: bool = False, seen: set|None = None) -> Iterable[Node]:
if recurse and seen is None:
seen = set()
for child in self._children():
if isinstance(child, atype):
yield child
if recurse and isinstance(child, Node) and id(child) not in seen:
seen.add(id(child))
yield from child._children_of_type(atype=atype, recurse=True, seen=seen)