schema compile CHANGE compiling leafref types

- allow sharing type structure if it does not change since it does not
contain resolved target node which can differ for each instance
- remember correct context module for the leafref path since it may
contain prefixes which are valid only in the module where the path was
defined.
diff --git a/src/tree_schema_helpers.c b/src/tree_schema_helpers.c
index 6f3815c..5484999 100644
--- a/src/tree_schema_helpers.c
+++ b/src/tree_schema_helpers.c
@@ -980,3 +980,16 @@
     }
 }
 
+struct lys_module *
+lysp_find_module(struct ly_ctx *ctx, const struct lysp_module *mod)
+{
+    unsigned int u;
+
+    for (u = 0; u < ctx->list.count; ++u) {
+        if (((struct lys_module*)ctx->list.objs[u])->parsed == mod) {
+            return ((struct lys_module*)ctx->list.objs[u]);
+        }
+    }
+    return NULL;
+}
+