public static int safelyComputeTreeSize(Cons tree, int depthcount, int cutoff) {
    { int count = 1;
      Stella_Object value = null;

      if (depthcount > Stella.$DEPTHCUTOFF$) {
        Native.setBooleanSpecial(Stella.$DEPTHEXCEEDEDp$, true);
        return (1);
      }
      for (;;) {
        value = tree.value;
        if (Stella_Object.consP(value)) {
          count = count + Cons.safelyComputeTreeSize(((Cons)(tree.value)), depthcount + 1, cutoff);
        }
        if ((tree.rest == null) ||
            ((tree.rest == Stella.NIL) ||
             (count > cutoff))) {
          return (count);
        }
        tree = tree.rest;
      }
    }
  }