public void batchRelate(
      ModelRoot modelRoot, boolean relateProxies, boolean notifyChanges, boolean searchAllRoots) {
    InstanceList instances = null;
    ModelRoot baseRoot = modelRoot;

    if (ReferencesVariable == null) {
      // R805
      Variable_c relInst37416 =
          (Variable_c) baseRoot.getInstanceList(Variable_c.class).get(new Object[] {m_var_id});
      // if there was no local element, check for any global elements
      // failing that proceed to check other model roots
      if (relInst37416 == null) {
        relInst37416 =
            (Variable_c)
                Ooaofooa.getDefaultInstance()
                    .getInstanceList(Variable_c.class)
                    .get(new Object[] {m_var_id});
      }
      if (relInst37416 == null && searchAllRoots && !baseRoot.isCompareRoot()) {
        Ooaofooa[] roots = Ooaofooa.getInstances();
        for (int i = 0; i < roots.length; i++) {
          if (roots[i].isCompareRoot()) {
            // never use elements from any compare root
            continue;
          }
          relInst37416 =
              (Variable_c) roots[i].getInstanceList(Variable_c.class).get(new Object[] {m_var_id});
          if (relInst37416 != null) break;
        }
      }
      // synchronized
      if (relInst37416 != null) {
        if (relateProxies || !isProxy() || (inSameComponent(this, relInst37416) && !isProxy())) {
          relInst37416.relateAcrossR805To(this, notifyChanges);
        }
      }
    }

    // R801
    Value_c relInst37417 =
        (Value_c) baseRoot.getInstanceList(Value_c.class).get(new Object[] {m_value_id});
    // if there was no local element, check for any global elements
    // failing that proceed to check other model roots
    if (relInst37417 == null) {
      relInst37417 =
          (Value_c)
              Ooaofooa.getDefaultInstance()
                  .getInstanceList(Value_c.class)
                  .get(new Object[] {m_value_id});
    }
    if (relInst37417 == null && searchAllRoots && !baseRoot.isCompareRoot()) {
      Ooaofooa[] roots = Ooaofooa.getInstances();
      for (int i = 0; i < roots.length; i++) {
        if (roots[i].isCompareRoot()) {
          // never use elements from any compare root
          continue;
        }
        relInst37417 =
            (Value_c) roots[i].getInstanceList(Value_c.class).get(new Object[] {m_value_id});
        if (relInst37417 != null) break;
      }
    }
    // synchronized
    if (relInst37417 != null) {
      if (relateProxies || !isProxy() || (inSameComponent(this, relInst37417) && !isProxy())) {
        relInst37417.relateAcrossR801To(this, notifyChanges);
      }
    }
  }