public static void helpInsertACsValue(KvCons kvcons, Stella_Object newvalue, Context target, boolean overwriteP) {
    { int contextnumber = target.contextNumber;

      for (;;) {
        if ((!Stella.$CONTEXT_BACKTRACKING_MODE$) &&
            (Stella.$UNLINK_DISCARDED_CONTEXTS_ON_WRITEp$ &&
             (((((Context)(kvcons.key)).contextNumber) % 2) == 1))) {
          if (kvcons.rest != null) {
            { KvCons nextkvcons = kvcons.rest;

              kvcons.key = nextkvcons.key;
              kvcons.value = nextkvcons.value;
              kvcons.rest = nextkvcons.rest;
              nextkvcons.free();
            }
          }
          else {
            {
              kvcons.key = target;
              kvcons.value = newvalue;
              return;
            }
          }
        }
        if (kvcons.key == target) {
          if (overwriteP) {
            kvcons.value = newvalue;
          }
          return;
        }
        else if (((Context)(kvcons.key)).contextNumber < contextnumber) {
          kvcons.rest = KvCons.kvCons(kvcons.key, kvcons.value, kvcons.rest);
          kvcons.key = target;
          kvcons.value = newvalue;
          return;
        }
        else if (kvcons.rest == null) {
          kvcons.rest = KvCons.kvCons(target, newvalue, null);
          return;
        }
        else {
          kvcons = kvcons.rest;
        }
      }
    }
  }