Add check for Root Node to the parent function
[SXSI/XMLTree.git] / XMLTree.cpp
index 3c51b2f..21658e9 100644 (file)
@@ -311,8 +311,10 @@ treeNode XMLTree::Parent(treeNode x)
        fprintf(stderr, "Error: data structure has not been constructed properly\n");\r
        exit(1);\r
     }\r
-\r
-    return parent(Par, x);\r
+    if (x == Root())\r
+      return NULLT;\r
+    else\r
+      return parent(Par, x);\r
  }\r
 \r
 // Child(x,i): returns the i-th child of node x, assuming it exists.\r