When deleting a document/folder we need to find the ids of all descendant documents in order to invalidate them and clean caches.
However when path optimizations are not enabled, this requires a full scan of the database and execution of NX_IN_TREE on each of them, which is very costly. Instead, we can do an iterative child traversal starting from the deleted document to find the descendants depth by depth. This will be must faster.