they're killed. */
 void jffs2_kill_fragtree(struct rb_root *root, struct jffs2_sb_info *c)
 {
-       struct jffs2_node_frag *frag;
-       struct jffs2_node_frag *parent;
-
-       if (!root->rb_node)
-               return;
+       struct jffs2_node_frag *frag, *next;
 
        dbg_fragtree("killing\n");
-
-       frag = (rb_entry(root->rb_node, struct jffs2_node_frag, rb));
-       while(frag) {
-               if (frag->rb.rb_left) {
-                       frag = frag_left(frag);
-                       continue;
-               }
-               if (frag->rb.rb_right) {
-                       frag = frag_right(frag);
-                       continue;
-               }
-
+       rbtree_postorder_for_each_entry_safe(frag, next, root, rb) {
                if (frag->node && !(--frag->node->frags)) {
                        /* Not a hole, and it's the final remaining frag
                           of this node. Free the node */
 
                        jffs2_free_full_dnode(frag->node);
                }
-               parent = frag_parent(frag);
-               if (parent) {
-                       if (frag_left(parent) == frag)
-                               parent->rb.rb_left = NULL;
-                       else
-                               parent->rb.rb_right = NULL;
-               }
 
                jffs2_free_node_frag(frag);
-               frag = parent;
-
                cond_resched();
        }
 }
 
 
 static void jffs2_free_tmp_dnode_info_list(struct rb_root *list)
 {
-       struct rb_node *this;
-       struct jffs2_tmp_dnode_info *tn;
-
-       this = list->rb_node;
+       struct jffs2_tmp_dnode_info *tn, *next;
 
-       /* Now at bottom of tree */
-       while (this) {
-               if (this->rb_left)
-                       this = this->rb_left;
-               else if (this->rb_right)
-                       this = this->rb_right;
-               else {
-                       tn = rb_entry(this, struct jffs2_tmp_dnode_info, rb);
+       rbtree_postorder_for_each_entry_safe(tn, next, list, rb) {
                        jffs2_free_full_dnode(tn->fn);
                        jffs2_free_tmp_dnode_info(tn);
-
-                       this = rb_parent(this);
-                       if (!this)
-                               break;
-
-                       if (this->rb_left == &tn->rb)
-                               this->rb_left = NULL;
-                       else if (this->rb_right == &tn->rb)
-                               this->rb_right = NULL;
-                       else BUG();
-               }
        }
+
        *list = RB_ROOT;
 }