private BTNode removeNode(BTNode p, Comparable target)
   {  
      if(p == null)  // tree is empty, target is not found 
         return p;
      int answer = target.compareTo(root.getData());
   	if(answer == -1) 
  	      p.setLeft( removeNode( p.getLeft(), target));
  	   else if(answer == 1)
         p.setRight( removeNode(p.getRight(), target));
          
         //found the node to be removed

         //if the node has two children 
      else if((p.getLeft() != null) && (p.getRight() != null)) 
   	{      
 		   // get the data in the right most node in the left subtree 
         p.setData(p.getLeft().getRightmostData());
        	// delete the right most data in the left subtree
         p.setLeft(p.getLeft().removeRightmost() );
  	   }

      else if (p.getLeft() ==null)           
      //only right child
         p = p.getRight();
      else                                              
      // only left child 
		   p = p.getLeft();
      return p;      
   }