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