test for completion of traversal or for q containing a pointer to the right subtree to be trasversed next; note that p will be null if the tranversal is done

}while(!empty(&s)&&(q==rightpointer));