public static Stella_Object helpCoerceATree(Stella_Object tree, StandardObject sourcetype, StandardObject targettype, boolean testonlyP, Object [] MV_returnarray) {
    { Stella_Object coersionfunction = null;
      Surrogate realsourcetype = Stella_Object.targetLanguageType(tree);
      Surrogate sourcebasetype = StandardObject.typeSpecToBaseType(sourcetype);
      Surrogate targetbasetype = StandardObject.typeSpecToBaseType(targettype);

      if (sourcetype == Stella.SGT_STELLA_UNKNOWN) {
        Stella_Object.warnAboutUnknownSourceType(tree);
        if ((tree == Stella.SYM_STELLA_NULL) &&
            (targetbasetype != null)) {
          { Stella_Object _return_temp = StandardObject.typeToWalkedNullValueTree(targettype, targetbasetype);

            MV_returnarray[0] = targettype;
            MV_returnarray[1] = BooleanWrapper.wrapBoolean(true);
            return (_return_temp);
          }
        }
        else {
          { Stella_Object _return_temp = tree;

            MV_returnarray[0] = targettype;
            MV_returnarray[1] = BooleanWrapper.wrapBoolean(true);
            return (_return_temp);
          }
        }
      }
      if (realsourcetype != null) {
        Cons.setTargetLanguageType(((Cons)(tree)), null, new Object[1]);
        tree = Stella_Object.coerceATree(tree, realsourcetype, sourcetype, new Object[1]);
      }
      if (targettype == Stella.SGT_STELLA_UNKNOWN) {
        { Stella_Object _return_temp = tree;

          MV_returnarray[0] = sourcetype;
          MV_returnarray[1] = BooleanWrapper.wrapBoolean(true);
          return (_return_temp);
        }
      }
      if (((Stella_Class)(sourcebasetype.surrogateValue)) == null) {
        { Object old$PrintreadablyP$000 = Stella.$PRINTREADABLYp$.get();

          try {
            Native.setBooleanSpecial(Stella.$PRINTREADABLYp$, true);
            Stella.signalTranslationError();
            if (!(Stella.suppressWarningsP())) {
              Stella.printErrorContext(">> ERROR: ", Stella.STANDARD_ERROR);
              {
                Stella.STANDARD_ERROR.nativeStream.println();
                Stella.STANDARD_ERROR.nativeStream.println(" No class defined for type: `" + Stella_Object.deUglifyParseTree(sourcebasetype) + "'.");
              }
;
            }

          } finally {
            Stella.$PRINTREADABLYp$.set(old$PrintreadablyP$000);
          }
        }
        { Stella_Object _return_temp = tree;

          MV_returnarray[0] = targettype;
          MV_returnarray[1] = BooleanWrapper.wrapBoolean(true);
          return (_return_temp);
        }
      }
      if ((targetbasetype != null) &&
          (((Stella_Class)(targetbasetype.surrogateValue)) == null)) {
        { Object old$PrintreadablyP$001 = Stella.$PRINTREADABLYp$.get();

          try {
            Native.setBooleanSpecial(Stella.$PRINTREADABLYp$, true);
            Stella.signalTranslationError();
            if (!(Stella.suppressWarningsP())) {
              Stella.printErrorContext(">> ERROR: ", Stella.STANDARD_ERROR);
              {
                Stella.STANDARD_ERROR.nativeStream.println();
                Stella.STANDARD_ERROR.nativeStream.println(" No class defined for type: `" + Stella_Object.deUglifyParseTree(targetbasetype) + "'.");
              }
;
            }

          } finally {
            Stella.$PRINTREADABLYp$.set(old$PrintreadablyP$001);
          }
        }
        { Stella_Object _return_temp = tree;

          MV_returnarray[0] = sourcetype;
          MV_returnarray[1] = BooleanWrapper.wrapBoolean(true);
          return (_return_temp);
        }
      }
      if (StandardObject.subTypeSpecOfP(sourcetype, targettype)) {
        { Stella_Object _return_temp = tree;

          MV_returnarray[0] = sourcetype;
          MV_returnarray[1] = BooleanWrapper.wrapBoolean(true);
          return (_return_temp);
        }
      }
      if ((targetbasetype != null) &&
          (StandardObject.compatibleParameterTypesP(sourcetype, targettype) ||
           ((!StandardObject.arrayTypeSpecifierP(sourcetype)) &&
            (Surrogate.subtypeOfP(targetbasetype, sourcebasetype) &&
             StandardObject.compatibleParameterTypesP(targettype, sourcetype))))) {
        { boolean testValue000 = false;

          testValue000 = Stella_Object.typeP(sourcetype);
          if (testValue000) {
            { 
              coersionfunction = Surrogate.lookupCoersionMethod(((Surrogate)(sourcetype)), targetbasetype, tree);
              testValue000 = coersionfunction != null;
            }
          }
          if (testValue000) {
            if (!(testonlyP)) {
              { Object [] caller_MV_returnarray = new Object[1];

                tree = Stella_Object.applyCoercionMethod(tree, ((Surrogate)(sourcetype)), targetbasetype, coersionfunction, caller_MV_returnarray);
                targettype = ((StandardObject)(caller_MV_returnarray[0]));
              }
            }
            { Stella_Object _return_temp = tree;

              MV_returnarray[0] = targettype;
              MV_returnarray[1] = BooleanWrapper.wrapBoolean(true);
              return (_return_temp);
            }
          }
        }
        if (Surrogate.subtypeOfP(targetbasetype, sourcebasetype)) {
          if (testonlyP) {
            { Stella_Object _return_temp = tree;

              MV_returnarray[0] = targettype;
              MV_returnarray[1] = BooleanWrapper.wrapBoolean(true);
              return (_return_temp);
            }
          }
          { Stella_Object _return_temp = Stella_Object.walkWithoutTypeTree(Cons.cons(((realsourcetype != null) ? Stella.SYM_STELLA_SAFE_CAST : Stella.SYM_STELLA_CAST), Cons.cons(tree, Cons.cons(targettype, Stella.NIL))));

            MV_returnarray[0] = targettype;
            MV_returnarray[1] = BooleanWrapper.wrapBoolean(true);
            return (_return_temp);
          }
        }
        if (Surrogate.subtypeOfP(targetbasetype, Stella.SGT_STELLA_NON_OBJECT) &&
            (Stella_Object.typeP(sourcetype) &&
             Surrogate.subtypeOfP(Stella.SGT_STELLA_WRAPPER, ((Surrogate)(sourcetype))))) {
          { Surrogate wrappertype = targetbasetype.typeToWrappedType();

            if (wrappertype != null) {
              if (testonlyP) {
                { Stella_Object _return_temp = tree;

                  MV_returnarray[0] = targettype;
                  MV_returnarray[1] = BooleanWrapper.wrapBoolean(true);
                  return (_return_temp);
                }
              }
              coersionfunction = Surrogate.lookupCoersionMethod(wrappertype, targetbasetype, tree);
              if (coersionfunction != null) {
                { Object [] caller_MV_returnarray = new Object[1];

                  tree = Stella_Object.applyCoercionMethod(Cons.list$(Cons.cons(Stella.SYM_STELLA_CAST, Cons.cons(tree, Cons.cons(Cons.cons(wrappertype, Stella.NIL), Stella.NIL)))), ((Surrogate)(sourcetype)), targetbasetype, coersionfunction, caller_MV_returnarray);
                  targettype = ((StandardObject)(caller_MV_returnarray[0]));
                }
                { Stella_Object _return_temp = tree;

                  MV_returnarray[0] = targettype;
                  MV_returnarray[1] = BooleanWrapper.wrapBoolean(true);
                  return (_return_temp);
                }
              }
            }
          }
        }
      }
      { Stella_Object _return_temp = tree;

        MV_returnarray[0] = sourcetype;
        MV_returnarray[1] = BooleanWrapper.wrapBoolean(false);
        return (_return_temp);
      }
    }
  }