protected function _pruneTree(int $depth): int
    {
        for ($i = $depth; $i > 0; --$i) {
            foreach ($this->_nodesAtDepth($i) as $node) {
                if (!count($node)) {
                    $node->remove();
                }
            }
        }
        // if root has no children left
        if (!count($this->_root)) {
            $this->_root = null;
            return 0;
        }
        return $this->_root->nodeCount();
    }
protected function _pruneTree(int $depth): int
    {
        for ($i = $depth; $i > 0; --$i) {
            foreach ($this->_nodesAtDepth($i) as $node) {
                if (!count($node)) {
                    $node->remove();
                }
            }
        }
        // if root has no children left
        if (!count($this->_root)) {
            $this->_root = null;
            return 0;
        }
        return $this->_root->nodeCount();
    }
protected function _pruneTree ( int $ depth ) : int { for ( $ i = $ depth ; $ i > 0 ; -- $ i ) { foreach ( $ this -> _nodesAtDepth ( $ i ) as $ node ) { if ( ! count ( $ node ) ) { $ node -> remove ( ) ; } } } // if root has no children left if ( ! count ( $ this -> _root ) ) { $ this -> _root = null ; return 0 ; } return $ this -> _root -> nodeCount ( ) ; }
Prune tree starting from given depth.

@param int $depth
@return int The number of nodes left in a tree
Prune tree starting from given depth .