tree schema BUGFIX invalid implemented non-import module message
diff --git a/src/tree_schema.c b/src/tree_schema.c
index 14deebd..3f080ac 100644
--- a/src/tree_schema.c
+++ b/src/tree_schema.c
@@ -844,11 +844,10 @@
     /* Try to find module with LYS_MOD_IMPORTED_REV flag. */
     i = 0;
     while ((mod_iter = ly_ctx_get_module_iter(mod->ctx, &i))) {
-        if (!strcmp(mod_iter->name, mod->name) && (mod_iter->latest_revision & LYS_MOD_IMPORTED_REV)) {
-            LOGVRB("Implemented module \"%s@%s\" was not and will not "
-                    "be imported if the revision-date is missing in the "
-                    "import statement. Instead, the revision \"%s\" "
-                    "is imported.", mod->name, mod->revision, mod_iter->revision);
+        if (!strcmp(mod_iter->name, mod->name) && (mod_iter != mod) && (mod_iter->latest_revision & LYS_MOD_IMPORTED_REV)) {
+            LOGVRB("Implemented module \"%s@%s\" was not and will not be imported if the revision-date is missing"
+                    " in the import statement. Instead, the revision \"%s\" is imported.", mod->name, mod->revision,
+                    mod_iter->revision);
             break;
         }
     }