diff --git a/src/Plugin/Block/SuperfishBlock.php b/src/Plugin/Block/SuperfishBlock.php
index e65fe5b..b84e70d 100644
--- a/src/Plugin/Block/SuperfishBlock.php
+++ b/src/Plugin/Block/SuperfishBlock.php
@@ -935,7 +935,12 @@ class SuperfishBlock extends SystemMenuBlock {
   /**
    * Loads the whole menu tree.
    */
-  public function expandAll($tree) {
+  public function expandAll($tree, $currentDepth = 1) {
+    $maxDepth = $this->configuration['depth'];
+    if ($currentDepth >= $maxDepth) {
+      return $tree;
+    }
+
     // Sorts the tree based on link "weights".
     usort($tree, function($a, $b) {
       $link_a = $a->link->getPluginDefinition();
@@ -949,7 +954,8 @@ class SuperfishBlock extends SystemMenuBlock {
         $parameters->setRoot($element->link->getPluginId())->excludeRoot()->setMaxDepth(1)->onlyEnabledLinks();
         $subtree = $menu_tree->load(NULL, $parameters);
         if ($subtree) {
-          $tree[$key]->subtree = $this->expandAll($subtree);
+          $nextDepth = $currentDepth + 1;
+          $tree[$key]->subtree = $this->expandAll($subtree, $nextDepth);
         }
       }
     }
@@ -1012,4 +1018,4 @@ class SuperfishBlock extends SystemMenuBlock {
     ];
   }
 
-}
\ No newline at end of file
+}
