schema tree BUGFIX always return module on success from parsing

If the module was already in the context,
it must be returned.
diff --git a/src/tree_schema.c b/src/tree_schema.c
index 4470fbe..b64665c 100644
--- a/src/tree_schema.c
+++ b/src/tree_schema.c
@@ -1389,7 +1389,13 @@
 
 free_mod_cleanup:
     lys_module_free(mod, NULL);
-    mod = NULL;
+    if (ret) {
+        mod = NULL;
+    } else {
+        /* return the existing module */
+        assert(mod_dup);
+        mod = mod_dup;
+    }
 
 cleanup:
     if (pctx) {