lib/PHPPdf/Core/Node/Node.php
public function getAncestorByType($type)
    {
        $current = $this;
        do
        {
            $parent = $current->parent;
            $current = $parent;
        }
        while($parent && !$parent instanceof $type);

        return $parent;
    }
public function getAncestorByType($type)
    {
        $current = $this;
        do
        {
            $parent = $current->parent;
            $current = $parent;
        }
        while($parent && !$parent instanceof $type);

        return $parent;
    }
public function getAncestorByType ( $ type ) { $ current = $ this ; do { $ parent = $ current -> parent ; $ current = $ parent ; } while ( $ parent && ! $ parent instanceof $ type ) ; return $ parent ; }
Gets ancestor with passed type. If ancestor has not been found, null will be returned.

@param string $type Full class name with namespace
@return PHPPdf\Core\Node\Node Nearest ancestor in $type
Gets ancestor with passed type . If ancestor has not been found null will be returned .