table: cleanupOnFaceRemoval doesn't rely on shared_ptr<name_tree::Entry> anymore

refs #3687

Change-Id: I3901f053bf370ca5a19a0fea72aec8eb58fcfe10
diff --git a/daemon/table/name-tree.cpp b/daemon/table/name-tree.cpp
index b806cd4..adff4b3 100644
--- a/daemon/table/name-tree.cpp
+++ b/daemon/table/name-tree.cpp
@@ -118,7 +118,7 @@
 }
 
 size_t
-NameTree::eraseIfEmpty(Entry* entry)
+NameTree::eraseIfEmpty(Entry* entry, bool canEraseAncestors)
 {
   BOOST_ASSERT(entry != nullptr);
 
@@ -132,6 +132,10 @@
 
     m_ht.erase(getNode(*entry));
     ++nErased;
+
+    if (!canEraseAncestors) {
+      break;
+    }
   }
 
   if (nErased == 0) {