+ search_key = malloc(sizeof *search_key + strlen(name) + 1);
+ if (!search_key)
+ return -1;
+
+ search_key->pkg = (GTypeModule) {
+ .name = str_cpy_lower(search_key->buf, name),
+ };
+
+ result = avl_find(package_tree, search_key);
+ free(search_key);
+
+ *out = result;
+ return 0;
+}
+
+GTypeModule *
+u_module_get_from_import(GTypeModule *pkg, const struct upkg_import *i)
+{
+ GTypeModule *result;
+
+ while (i->parent != NULL)
+ i = i->parent;
+
+ if (strcmp(i->class_package, "Core") != 0
+ || strcmp(i->class_name, "Package") != 0) {
+ u_err(pkg, "import root must be an instance of Core.Package");
+ return NULL;
+ }
+
+ if (lookup_module(&result, i->name) != 0) {
+ u_err(pkg, "fatal error performing package lookup");
+ return NULL;
+ }
+
+ if (!result) {