schema compile CHANGE partial support for choice/case nodes

- still work in progress - missing choice's default statement support
and most of the unit tests.
diff --git a/src/tree_schema_free.c b/src/tree_schema_free.c
index 9b7a3b5..28be01d 100644
--- a/src/tree_schema_free.c
+++ b/src/tree_schema_free.c
@@ -585,8 +585,6 @@
 {
     struct lysc_node *child, *child_next;
 
-    FREE_MEMBER(ctx, node->when, lysc_when_free);
-    FREE_ARRAY(ctx, node->iffeatures, lysc_iffeature_free);
     LY_LIST_FOR_SAFE(node->child, child_next, child) {
         lysc_node_free(ctx, child);
     }
@@ -598,8 +596,6 @@
 static void
 lysc_node_leaf_free(struct ly_ctx *ctx, struct lysc_node_leaf *node)
 {
-    FREE_MEMBER(ctx, node->when, lysc_when_free);
-    FREE_ARRAY(ctx, node->iffeatures, lysc_iffeature_free);
     FREE_ARRAY(ctx, node->musts, lysc_must_free);
     if (node->type) {
         lysc_type_free(ctx, node->type);
@@ -613,8 +609,6 @@
 {
     unsigned int u;
 
-    FREE_MEMBER(ctx, node->when, lysc_when_free);
-    FREE_ARRAY(ctx, node->iffeatures, lysc_iffeature_free);
     FREE_ARRAY(ctx, node->musts, lysc_must_free);
     if (node->type) {
         lysc_type_free(ctx, node->type);
@@ -632,8 +626,6 @@
     unsigned int u;
     struct lysc_node *child, *child_next;
 
-    FREE_MEMBER(ctx, node->when, lysc_when_free);
-    FREE_ARRAY(ctx, node->iffeatures, lysc_iffeature_free);
     LY_LIST_FOR_SAFE(node->child, child_next, child) {
         lysc_node_free(ctx, child);
     }
@@ -648,6 +640,24 @@
     /* TODO actions, notifs */
 }
 
+static void
+lysc_node_choice_free(struct ly_ctx *ctx, struct lysc_node_choice *node)
+{
+    struct lysc_node *child, *child_next;
+
+    FREE_MEMBER(ctx, node->when, lysc_when_free);
+    FREE_ARRAY(ctx, node->iffeatures, lysc_iffeature_free);
+    if (node->cases) {
+        LY_LIST_FOR_SAFE(node->cases->child, child_next, child) {
+            lysc_node_free(ctx, child);
+        }
+        LY_LIST_FOR_SAFE((struct lysc_node*)node->cases, child_next, child) {
+            lysc_node_free(ctx, child);
+        }
+    }
+
+}
+
 void
 lysc_node_free(struct ly_ctx *ctx, struct lysc_node *node)
 {
@@ -668,10 +678,19 @@
     case LYS_LIST:
         lysc_node_list_free(ctx, (struct lysc_node_list*)node);
         break;
+    case LYS_CHOICE:
+        lysc_node_choice_free(ctx, (struct lysc_node_choice*)node);
+        break;
+    case LYS_CASE:
+        /* nothing specific */
+        break;
     default:
         LOGINT(ctx);
     }
 
+    FREE_MEMBER(ctx, node->when, lysc_when_free);
+    FREE_ARRAY(ctx, node->iffeatures, lysc_iffeature_free);
+    FREE_ARRAY(ctx, node->exts, lysc_ext_instance_free);
     free(node);
 }