src/Nodes/NodeTrait.php
public function getNodeAncestors($maxLevel = 3)
    {
        $ancestors = [];
        $level = 0;

        $node = $this->parentNode;

        while ($node && !($node instanceof DOMDocument)) {
            $ancestors[] = $node;
            $level++;
            if ($level === $maxLevel) {
                break;
            }
            $node = $node->parentNode;
        }

        return $ancestors;
    }
public function getNodeAncestors($maxLevel = 3)
    {
        $ancestors = [];
        $level = 0;

        $node = $this->parentNode;

        while ($node && !($node instanceof DOMDocument)) {
            $ancestors[] = $node;
            $level++;
            if ($level === $maxLevel) {
                break;
            }
            $node = $node->parentNode;
        }

        return $ancestors;
    }
public function getNodeAncestors ( $ maxLevel = 3 ) { $ ancestors = [ ] ; $ level = 0 ; $ node = $ this -> parentNode ; while ( $ node && ! ( $ node instanceof DOMDocument ) ) { $ ancestors [ ] = $ node ; $ level ++ ; if ( $ level === $ maxLevel ) { break ; } $ node = $ node -> parentNode ; } return $ ancestors ; }
Get the ancestors of the current node.

@param int|bool $maxLevel Max amount of ancestors to get. False for all of them

@return array
Get the ancestors of the current node .