+static Node *
+new_term (char *text)
+{
+ Node *node = (Node *) malloc (sizeof (Node));
+ node->term.isNterm = 0;
+ node->term.parents = 0;
+ node->term.text = text;
+ return node;
+}
+
+static void
+free_node (Node *node)
+{
+ if (!node)
+ return;
+ node->nodeInfo.parents -= 1;
+ /* Free only if 0 (last parent) or -1 (no parents). */
+ if (node->nodeInfo.parents > 0)
+ return;
+ if (node->nodeInfo.isNterm == 1)
+ {
+ free_node (node->nterm.children[0]);
+ free_node (node->nterm.children[1]);
+ free_node (node->nterm.children[2]);
+ }
+ else
+ free (node->term.text);
+ free (node);
+}