/* The tree may not be modified while iterating over it (you can't add/remove items). To remove all items matching a predicate, you need to add each item to a list in your #GTraverseFunc as you walk over the tree, then walk the list and remove each item.  */
void g_tree_foreach(GTree *tree, GTraverseFunc func, gpointer user_data)
/* The tree may not be modified while iterating over it (you can't add/remove items). To remove all items matching a predicate, you need to add each item to a list in your #GTraverseFunc as you walk over the tree, then walk the list and remove each item.  */
void g_tree_foreach(GTree *tree, GTraverseFunc func, gpointer user_data)
{
  GTreeNode *node;
  g_return_if_fail (tree != NULL);
  if (!tree->root)
    return;
  node = g_tree_first_node (tree);
  while (node)
    {
      if ((*func) (node->key, node->value, user_data))
        break;
      node = g_tree_node_next (node);
    }
}