dentry.c: Fix broken tree traversal functions