diff --git a/src/Node/Node.php b/src/Node/Node.php
index 25d2b3e..2282fff 100644
--- a/src/Node/Node.php
+++ b/src/Node/Node.php
@@ -170,6 +170,6 @@ public function withChildren(NodeInterface ...$nodes): NodeInterface
      */
     public function depth(): int
     {
-        return \count(\iterator_to_array($this->getAncestors()));
+        return \iterator_count($this->getAncestors());
     }
 }