mini programmer 0 Junior Poster in Training

Hi to all
I have ADT of the AVL TREE and I need to add some the function to create tree to family.

I have logic error in my code..
my code work to find relationship between two nodes (e.g: a parent of b,a and b are Sibling and so on)
but it doesn't work correctly


I put the out put statement in my code , to help me to see where the error create
but now I do not know is the error
ex : If we find if node (a ) grand parent of node (b) . mean
the level of (a) is greater than (b) with 2
So I write this function

int  AvlTree<TYPE,KTYPE>:: AVL_Relation (KTYPE key1, KTYPE key2 )
{ 	NODE<TYPE> *node;
	if (! tree)
		return -3;
	int count1=0, count2 =0 , count3;
	node = _Relation  (key1 , tree ,count1);
	node = _Relation  (key2 ,tree ,count2 );
	
	count3= count1- count2 ;
	switch (count3)
	{
	case (0): 
			return 0;
	case (1):
		return 1 ; 
	case (-1):
		return -1 ; 
	case (2) :
			return 2 ;
	case (-2):
		return -2 ;
	}
	return 0 ;
} 

NODE<TYPE>* AvlTree<TYPE, KTYPE>:: _Relation (KTYPE key,NODE<TYPE> *root , int & c) 
{ 
	// statements
	if (root)
	{
		if (key < root->data.key)
		{
			 c++;
			return  _Relation  (key, root->left , c );
		}
		else 

			if (key > root->data.key)
			{
				 c++;
				return  _Relation  (key, root->right ,c);
			}
			


			else
			// Found equal key
			return (root);
	} // if root
	else
		//Data not in tree
		return root;
}

the error is the counter in the _Relation is count the correct. if the node (a ) parent of node (b) or node (a ) child of node (b)
but if node (a ) grand parent of node (b) or node (a ) grand child of node (b) is count once in 1 or -1

I want Know how .??

I hope to help me


greeting