return tree;
}
+/*
+ * bintree_find - Find a node from a tree.
+ *
+ * If node is found, pointer to the node is returned. If no node is
+ * found, null is returned.
+ */
+struct bintree *bintree_find(struct bintree *tree, struct bintree *new,
+ struct bintree_ops *ops)
+{
+ int ret;
+
+ if (tree == NULL)
+ return NULL;
+
+ ret = ops->compare(tree, new);
+ if (ret < 0) {
+ if (tree->left)
+ return bintree_find(tree->left, new, ops);
+
+ return NULL;
+ }
+
+ if (ret > 0) {
+ if (tree->right)
+ return bintree_find(tree->right, new, ops);
+
+ return NULL;
+ }
+
+ return tree;
+}
+
/*
* bintree_walk - walk through a binary tree from left to right
*