+// TaggedFoll(x,tag): returns the first node tagged tag with larger preorder than x and not in\r
+// the subtree of x. Returns NULLT if there is none.\r
+treeNode XMLTree::TaggedFollBelow(treeNode x, TagType tag, treeNode root)\r
+ {\r
+\r
+ int r, s;\r
+ int lim = node2tagpos(find_close(Par,root));\r
+ if (x ==NULLT || x == Root())\r
+ return NULLT;\r
+ \r
+ r = (int) Tags->rank(tag,find_close(Par,x));\r
+ s = (int) Tags->select(tag, r+1); // select returns -1 in case that there is no r+1-th tag.\r
+ if (s==-1 || s >= lim) \r
+ return NULLT;\r
+ else \r
+ return tagpos2node(s);\r
+ } \r
+\r