schema helpers BUGFIX action and notification node when access
diff --git a/src/tree_schema_helpers.c b/src/tree_schema_helpers.c
index 2d645cb..ef3e0f9 100644
--- a/src/tree_schema_helpers.c
+++ b/src/tree_schema_helpers.c
@@ -1004,9 +1004,25 @@
     }
 
     do {
-        if (node->when) {
-            return *node->when;
+        switch (node->nodetype) {
+        case LYS_RPC:
+        case LYS_ACTION:
+            if (((struct lysc_action *)node)->when) {
+                return *((struct lysc_action *)node)->when;
+            }
+            break;
+        case LYS_NOTIF:
+            if (((struct lysc_notif *)node)->when) {
+                return *((struct lysc_notif *)node)->when;
+            }
+            break;
+        default:
+            if (node->when) {
+                return *node->when;
+            }
+            break;
         }
+
         node = node->parent;
     } while (node && (node->nodetype & (LYS_CASE | LYS_CHOICE)));