def METHOD_NAME(
    self, leaves_only=False, with_ancestors=False
) -> Generator[NodeType, None, None]:
    """Recursive all nodes and leaves of the Group tree."""
    obj = self.root() if with_ancestors else self
    if not leaves_only:
        yield obj
    for child in obj:
        yield from child.METHOD_NAME(leaves_only)