return new;
}
+/*
+ * Recursively walk through the tree and propagate changes made to the
+ * given node up until the highest parent.
+ */
+static void quadtree_recalculate_parent_stats(struct quadtree *node,
+ struct quadtree_ops *ops)
+{
+ int i;
+
+ while (node) {
+ node->depth = 0;
+ node->children = 0;
+
+ for (i = 0; i < 4; i++) {
+ if (!node->child[i])
+ continue;
+
+ node->depth = MAX(node->depth,
+ node->child[i]->depth + 1);
+ node->children += node->child[i]->children + 1;
+ }
+
+ if (ops->recalculate_stats)
+ ops->recalculate_stats(node);
+
+ node = node->parent;
+ }
+}
+
/**
* quadtree_add - add a node to a quadtree
* @parent: parent node