schema compile CHANGE support list compilation
diff --git a/src/tree_schema.c b/src/tree_schema.c
index 537d3b6..9cb5860 100644
--- a/src/tree_schema.c
+++ b/src/tree_schema.c
@@ -92,11 +92,11 @@
     case LYS_CHOICE:
         if (options & LYS_GETNEXT_WITHCHOICE) {
             return next;
-        } else if (((struct lysc_node_choice *)next)->cases) {
+        } else if ((options & LYS_GETNEXT_NOCHOICE) || !((struct lysc_node_choice *)next)->cases) {
+            next = next->next;
+        } else {
             /* go into */
             next = ((struct lysc_node_choice *)next)->cases[0].child;
-        } else {
-            next = next->next;
         }
         goto repeat;
     default: