public int findNextNode(Node node, Node targetNode)
	{
		//targetNode not found
		if(node==null)
			return 0;
		
		if(node.equals(targetNode))
		{
			//its the root
			if(node.parent==null)
			{
				if(node.left==null)
					return node.id-=1;
				if(node.right==null)
					return node.id+=1;
			}
			else
			{
				if(node.left == null)
					return calculateNextNode(node,node.parent,true);
				if(node.right == null)
					return calculateNextNode(node,node.parent,false);
			}			
		}
		else
		{
			if(node.left == null)
				return findNextNode(node.left, targetNode);
			if(node.right == null)
				return findNextNode(node.right, targetNode);
		}
		return 0;
	}