public function getFirstAncestor(...$classNames) {
        $ancestor = $this;
        while (($ancestor = $ancestor->parent) !== null) {
            foreach ($classNames as $className) {
                if ($ancestor instanceof $className) {
                    return $ancestor;
                }
            }
        }
        return null;
    }
public function getFirstAncestor(...$classNames) {
        $ancestor = $this;
        while (($ancestor = $ancestor->parent) !== null) {
            foreach ($classNames as $className) {
                if ($ancestor instanceof $className) {
                    return $ancestor;
                }
            }
        }
        return null;
    }
public function getFirstAncestor ( ... $ classNames ) { $ ancestor = $ this ; while ( ( $ ancestor = $ ancestor -> parent ) !== null ) { foreach ( $ classNames as $ className ) { if ( $ ancestor instanceof $ className ) { return $ ancestor ; } } } return null ; }
Gets first ancestor that is an instance of one of the provided classes.
Returns null if there is no match.

@param string ...$classNames
@return Node|null
Gets first ancestor that is an instance of one of the provided classes . Returns null if there is no match .