public function dump() : Generator
    {
        $nodes = [];

        $stack = [$this->root];

        while ($stack) {
            $current = array_pop($stack);

            if ($current instanceof BinaryNode) {
                foreach ($current->children() as $child) {
                    $stack[] = $child;
                }
            }

            yield $current;
        }
    }
public function dump() : Generator
    {
        $nodes = [];

        $stack = [$this->root];

        while ($stack) {
            $current = array_pop($stack);

            if ($current instanceof BinaryNode) {
                foreach ($current->children() as $child) {
                    $stack[] = $child;
                }
            }

            yield $current;
        }
    }
public function dump ( ) : Generator { $ nodes = [ ] ; $ stack = [ $ this -> root ] ; while ( $ stack ) { $ current = array_pop ( $ stack ) ; if ( $ current instanceof BinaryNode ) { foreach ( $ current -> children ( ) as $ child ) { $ stack [ ] = $ child ; } } yield $ current ; } }
Return a generator for all the nodes in the tree starting at the root.

@return \Generator
Return a generator for all the nodes in the tree starting at the root .