diff --git a/src/cell_tree.hpp b/src/cell_tree.hpp
index ec7491c436a0035944c1b218c3ba936c99d3ad05..26fe9575b00c904ae873730745cbaabbedcf57db 100644
--- a/src/cell_tree.hpp
+++ b/src/cell_tree.hpp
@@ -173,7 +173,9 @@ public:
     {
         tree::iarray depth(num_segments());
         depth[0] = 0;
-        depth_from_root(depth, int_type{1});
+        for (auto c: children(0)) {
+            depth_from_root(depth, c);
+        }
         return depth;
     }
 
diff --git a/tests/unit/test_tree.cpp b/tests/unit/test_tree.cpp
index 610a2cab90f350093bf8b0e3c658fdc4141cb13d..49b36f758625a4c4a7faa3f8ac0055f83cb76e04 100644
--- a/tests/unit/test_tree.cpp
+++ b/tests/unit/test_tree.cpp
@@ -168,7 +168,6 @@ TEST(cell_tree, from_parent_index) {
         EXPECT_EQ(2u, tree.children(1)[0]);
         EXPECT_EQ(3u, tree.children(1)[1]);
     }
-    /* FIXME
     {
         //              0
         //             / \.
@@ -177,7 +176,7 @@ TEST(cell_tree, from_parent_index) {
         //          3   4
         //             / \.
         //            5   6
-        std::vector<int> parent_index = {0,0,0,1,1,4,4};
+        std::vector<int_type> parent_index = {0,0,0,1,1,4,4};
         cell_tree tree(parent_index);
 
         EXPECT_EQ(tree.num_segments(), 7u);
@@ -190,7 +189,49 @@ TEST(cell_tree, from_parent_index) {
         EXPECT_EQ(tree.num_children(5), 0u);
         EXPECT_EQ(tree.num_children(6), 0u);
     }
-    */
+}
+
+TEST(cell_tree, depth_from_root) {
+    {
+        //              0
+        //             / \.
+        //            1   2
+        //           / \.
+        //          3   4
+        //             / \.
+        //            5   6
+        std::vector<int_type> parent_index = {0,0,0,1,1,4,4};
+        cell_tree tree(parent_index);
+        auto depth = tree.depth_from_root();
+
+        EXPECT_EQ(depth[0], 0u);
+        EXPECT_EQ(depth[1], 1u);
+        EXPECT_EQ(depth[2], 1u);
+        EXPECT_EQ(depth[3], 2u);
+        EXPECT_EQ(depth[4], 2u);
+        EXPECT_EQ(depth[5], 3u);
+        EXPECT_EQ(depth[6], 3u);
+    }
+    {
+        //              0
+        //             / \.
+        //            1   2
+        //               / \.
+        //              3   4
+        //                 / \.
+        //                5   6
+        std::vector<int_type> parent_index = {0,0,0,2,2,4,4};
+        cell_tree tree(parent_index);
+        auto depth = tree.depth_from_root();
+
+        EXPECT_EQ(depth[0], 0u);
+        EXPECT_EQ(depth[1], 1u);
+        EXPECT_EQ(depth[2], 1u);
+        EXPECT_EQ(depth[3], 2u);
+        EXPECT_EQ(depth[4], 2u);
+        EXPECT_EQ(depth[5], 3u);
+        EXPECT_EQ(depth[6], 3u);
+    }
 }
 
 TEST(tree, change_root) {