void
bitree_remove_right(BiTree *tree, BiTreeNode *node)
{
	BiTreeNode **position;

	/* do not allow removal from an empty tree */
	if (bitree_size(tree) == 0)
		return;

	/* determine where to remove nodes */
	if (node == NULL)
		position = &tree->root;
	else
		position = &node->right;

	/* remove the nodes - recursive */
	if (*position != NULL) {
		bitree_remove_left(tree, *position);
		bitree_remove_right(tree, *position);

		if (tree->destroy != NULL) {
			/* call a user defined function to free dynamically allocated data */
			tree->destroy((*position)->data);
		}

		free(*position);
		*position = NULL;

		/* adjust the size of the tree to account for the remoced node */
		--tree->size;
	}
}
void bitree_remove_right(Bitree *tree, BiTreeNode *node) {
  BiTreeNode **position;

  if (bitree_size(tree) == 0)
    return;

  if (node == NULL)
    position = &tree->root;
  else
    position = &node->right;

  if (*position != NULL) {
    bitree_remove_right(tree, *position);
    bitree_remove_left(tree, *position);
    if (tree->destory != NULL)
      tree->destory((*position)->data);
    free(*position);
    *position = NULL;
    tree->size--;
  }
  return;
}
void bitree_destory(Bitree *tree) {
  bitree_remove_right(tree, NULL);
  memset(tree, 0, sizeof(Bitree));
  return;
}