Index: gtktreemodelsort.c
===================================================================
--- gtktreemodelsort.c	(revision 17289)
+++ gtktreemodelsort.c	(working copy)
@@ -1187,6 +1187,26 @@ gtk_tree_model_sort_ref_node (GtkTreeMod
 
   elt->ref_count++;
   level->ref_count++;
+
+  {
+    GtkTreeIter tmpiter;
+    SortLevel *parent_level = level->parent_level;
+    SortElt *parent_elt = level->parent_elt;
+
+    tmpiter.stamp = tree_model_sort->stamp;
+
+    while (parent_level)
+      {
+	tmpiter.user_data = parent_level;
+	tmpiter.user_data2 = parent_elt;
+
+	gtk_tree_model_sort_ref_node (tree_model, &tmpiter);
+
+	parent_elt = parent_level->parent_elt;
+	parent_level = parent_level->parent_level;
+      }
+  }
+
   if (level->ref_count == 1)
     {
       SortLevel *parent_level = level->parent_level;
@@ -1233,6 +1253,25 @@ gtk_tree_model_sort_real_unref_node (Gtk
   elt->ref_count--;
   level->ref_count--;
 
+  {
+    GtkTreeIter tmpiter;
+    SortLevel *parent_level = level->parent_level;
+    SortElt *parent_elt = level->parent_elt;
+
+    tmpiter.stamp = tree_model_sort->stamp;
+
+    while (parent_level)
+      {
+	tmpiter.user_data = parent_level;
+	tmpiter.user_data2 = parent_elt;
+
+	gtk_tree_model_sort_real_unref_node (tree_model, &tmpiter, FALSE);
+
+	parent_elt = parent_level->parent_elt;
+	parent_level = parent_level->parent_level;
+      }
+  }
+
   if (level->ref_count == 0)
     {
       SortLevel *parent_level = level->parent_level;
