schema tree CHANGE outer subtree dependency flag now also for leafref
diff --git a/src/resolve.c b/src/resolve.c
index 64b38df..6efcdc6 100644
--- a/src/resolve.c
+++ b/src/resolve.c
@@ -3572,7 +3572,7 @@
  */
 static int
 resolve_path_predicate_schema(const char *path, const struct lys_node *context_node,
-                              struct lys_node *parent)
+                              struct lys_node *parent, int parent_tpdf)
 {
     const struct lys_node *src_node, *dst_node;
     const char *path_key_expr, *source, *sour_pref, *dest, *dest_pref;
@@ -3618,6 +3618,10 @@
                 LOGVAL(LYE_NORESOLV, parent ? LY_VLOG_LYS : LY_VLOG_NONE, parent, "leafref predicate", path_key_expr);
                 return 0;
             }
+
+            if (!parent_tpdf && (dst_node->nodetype & (LYS_ACTION | LYS_NOTIF)) && lys_parent(dst_node)) {
+                parent->flags |= LYS_VALID_DEP;
+            }
         }
         while (1) {
             if (!dest_pref) {
@@ -3674,12 +3678,19 @@
     const struct lys_module *mod, *mod2;
     const char *id, *prefix, *name;
     int pref_len, nam_len, parent_times, has_predicate;
-    int i, first_iter, rc;
+    int i, first_iter, rc, in_act_notif = 0;
 
     first_iter = 1;
     parent_times = 0;
     id = path;
 
+    if (!parent_tpdf) {
+        for (node = lys_parent(parent); node && !(node->nodetype & (LYS_ACTION | LYS_NOTIF)); node = lys_parent(node));
+        if (node && lys_parent(node)) {
+            in_act_notif = 1;
+        }
+    }
+
     mod2 = lys_node_module(parent);
     do {
         if ((i = parse_path_arg(id, &prefix, &pref_len, &name, &nam_len, &parent_times, &has_predicate)) < 1) {
@@ -3700,6 +3711,11 @@
                            "leafref", path);
                     return EXIT_FAILURE;
                 }
+
+                if (in_act_notif && !parent_tpdf) {
+                    /* we started in an inner notification/action and have an absolute path */
+                    parent->flags |= LYS_VALID_DEP;
+                }
             } else if (parent_times > 0) {
                 if (parent_tpdf) {
                     /* the path is not allowed to contain relative path since we are in top level typedef */
@@ -3716,11 +3732,14 @@
                          node = lys_parent(node));
 
                     if (!node) {
-                        LOGVAL(LYE_NORESOLV, parent_tpdf ? LY_VLOG_NONE : LY_VLOG_LYS, parent_tpdf ? NULL : parent,
-                               "leafref", path);
+                        LOGVAL(LYE_NORESOLV, LY_VLOG_LYS, parent, "leafref", path);
                         return EXIT_FAILURE;
                     }
 
+                    if ((node->nodetype & (LYS_ACTION | LYS_NOTIF)) && lys_parent(node)) {
+                        assert(in_act_notif);
+                        parent->flags |= LYS_VALID_DEP;
+                    }
                 }
             } else {
                 LOGINT;
@@ -3754,7 +3773,7 @@
                 return -1;
             }
 
-            i = resolve_path_predicate_schema(id, node, parent);
+            i = resolve_path_predicate_schema(id, node, parent, parent_tpdf);
             if (i <= 0) {
                 if (i == 0) {
                     return EXIT_FAILURE;
@@ -5780,7 +5799,7 @@
                 for (elem = set.val.snodes[i].snode; elem && (elem != parent); elem = lys_parent(elem));
                 if (!elem) {
                     /* not in node's RPC or notification subtree, set the flag */
-                    node->flags |= LYS_XPATH_DEP;
+                    node->flags |= LYS_VALID_DEP;
                     break;
                 }
             }