protected function getNodesUntil($parentNodes, NodeInterface $until) { $count = count($parentNodes) - 1; for ($i = $count; $i >= 0; $i--) { if ($parentNodes[$i]->getPath() === $until->getPath()) { unset($parentNodes[$i]); return array_values($parentNodes); } else { unset($parentNodes[$i]); } } return array_values($parentNodes); }