docs: private void mergePackage(InternalKnowledgePackage pkg,
                                InternalKnowledgePackage newPkg) {
          // Merge imports
          final Map<String, ImportDeclaration> imports = pkg.getImports();
          imports.putAll(newPkg.getImports());
  
          String lastType = null;
          try {
              // merge globals
              if (newPkg.getGlobals() != null && newPkg.getGlobals() != Collections.EMPTY_MAP) {
                  Map<String, String> globals = pkg.getGlobals();
                  // Add globals
                  for (final Map.Entry<String, String> entry : newPkg.getGlobals().entrySet()) {
                      final String identifier = entry.getKey();
                      final String type = entry.getValue();
                      lastType = type;
                      if (globals.containsKey(identifier) && !globals.get(identifier).equals(type)) {
                          throw new RuntimeException(pkg.getName() + " cannot be integrated");
                      } else {
                          pkg.addGlobal(identifier,
                                        this.rootClassLoader.loadClass(type));
                          // this isn't a package merge, it's adding to the rulebase, but I've put it here for convenience
                          this.globals.put(identifier,
                                           this.rootClassLoader.loadClass(type));
                      }
                  }
              }
          } catch (ClassNotFoundException e) {
              throw new RuntimeException("Unable to resolve class '" + lastType + "'");
          }
  
          // merge the type declarations
          if (newPkg.getTypeDeclarations() != null) {
              // add type declarations
              for (TypeDeclaration type : newPkg.getTypeDeclarations().values()) {
                  // @TODO should we allow overrides? only if the class is not in use.
                  if (!pkg.getTypeDeclarations().containsKey(type.getTypeName())) {
                      // add to package list of type declarations
                      pkg.addTypeDeclaration(type);
                  }
              }
          }
  
          for (final org.kie.api.definition.rule.Rule newRule : newPkg.getRules()) {
              pkg.addRule(((RuleImpl) newRule));
          }
  
          //Merge The Rule Flows
          if (newPkg.getRuleFlows() != null) {
              final Map flows = newPkg.getRuleFlows();
              for (Object o : flows.values()) {
                  final Process flow = (Process) o;
                  pkg.addProcess(flow);
              }
          }
      }