schema tree FEATURE data schema path
diff --git a/src/tree_schema.c b/src/tree_schema.c
index a840121..be8b33c 100644
--- a/src/tree_schema.c
+++ b/src/tree_schema.c
@@ -348,11 +348,17 @@
 
     switch (pathtype) {
     case LYSC_PATH_LOG:
+    case LYSC_PATH_DATA:
         for (iter = node; iter && (iter != parent) && (len >= 0); iter = iter->parent) {
             char *s = buffer ? strdup(buffer) : path;
             char *id;
             const char *slash;
 
+            if ((pathtype == LYSC_PATH_DATA) && (iter->nodetype & (LYS_CHOICE | LYS_CASE))) {
+                /* schema-only node */
+                continue;
+            }
+
             id = strdup(iter->name);
             if (parent && (iter->parent == parent)) {
                 slash = "";