typedef struct TreeLinkNode BNode;


BNode* find_In(BNode* root)
{
	BNode* tmp;
	if (root == NULL)
		return NULL;
	tmp = root;
	while (!tmp&&!(tmp->left))
	{
		tmp = tmp->left;
	}
	return tmp->left;
}

BNode* Find_Next2( BNode* p)
{
	if (p->next == NULL)
		return NULL;
	else {
		if (p->next->left == p)
			return p->next;
		else
			return Find_Next2(p->next);
	}
}

BNode* Find_Next(BNode* p)
{
	if (!p)
		return NULL;
	if (p->right != NULL && p->right->left != NULL)
		return (find_In(p->right));
	else if (p->right != NULL)
	{
		return (p->right);
	}
	else if (p->next == NULL)
		return NULL;
	else {
		if (p->next->left == p)
			return p->next;
		else
			return Find_Next2(p->next);
	}

}


struct TreeLinkNode* GetNext(struct TreeLinkNode* pNode ) {
    BNode* next;
    if(pNode==NULL)
        return NULL;
    next=Find_Next(pNode);
    return next;
}