public static void collectUndeclaredVariables(Stella_Object tree, Cons declaredvariables, List undeclaredvariables) {
    { Surrogate testValue000 = Stella_Object.safePrimaryType(tree);

      if (testValue000 == Logic.SGT_STELLA_CONS) {
        { Cons tree000 = ((Cons)(tree));

          { Stella_Object operator = tree000.value;

            { Surrogate testValue001 = Stella_Object.safePrimaryType(operator);

              if (testValue001 == Logic.SGT_STELLA_CONS) {
                { Cons operator000 = ((Cons)(operator));

                  Logic.collectUndeclaredVariables(operator000, declaredvariables, undeclaredvariables);
                  { Stella_Object arg = null;
                    Cons iter000 = tree000.rest;

                    for (;!(iter000 == Stella.NIL); iter000 = iter000.rest) {
                      arg = iter000.value;
                      Logic.collectUndeclaredVariables(arg, declaredvariables, undeclaredvariables);
                    }
                  }
                }
              }
              else if (Surrogate.subtypeOfSymbolP(testValue001)) {
                { Symbol operator000 = ((Symbol)(operator));

                  if ((operator000 == Logic.SYM_STELLA_EXISTS) ||
                      (operator000 == Logic.SYM_STELLA_FORALL)) {
                    { Stella_Object v = null;
                      Cons iter001 = Logic.extractVariablesFromDeclarations(tree000.rest.value);

                      for (;!(iter001 == Stella.NIL); iter001 = iter001.rest) {
                        v = iter001.value;
                        declaredvariables = Cons.cons(v, declaredvariables);
                      }
                    }
                    { Stella_Object arg = null;
                      Cons iter002 = tree000.rest.rest;

                      for (;!(iter002 == Stella.NIL); iter002 = iter002.rest) {
                        arg = iter002.value;
                        Logic.collectUndeclaredVariables(arg, declaredvariables, undeclaredvariables);
                      }
                    }
                  }
                  else if ((operator000 == Logic.SYM_LOGIC_SETOFALL) ||
                      ((operator000 == Logic.SYM_LOGIC_KAPPA) ||
                       ((operator000 == Logic.SYM_LOGIC_LAMBDA) ||
                        (operator000 == Logic.SYM_LOGIC_THE)))) {
                  }
                  else {
                    { Stella_Object arg = null;
                      Cons iter003 = tree000.rest;

                      for (;!(iter003 == Stella.NIL); iter003 = iter003.rest) {
                        arg = iter003.value;
                        Logic.collectUndeclaredVariables(arg, declaredvariables, undeclaredvariables);
                      }
                    }
                  }
                }
              }
              else {
              }
            }
          }
        }
      }
      else if (Surrogate.subtypeOfSymbolP(testValue000)) {
        { Symbol tree000 = ((Symbol)(tree));

          if (Logic.questionMarkSymbolP(tree000) &&
              (!declaredvariables.memberP(tree000))) {
            if (!undeclaredvariables.memberP(tree000)) {
              undeclaredvariables.insertLast(tree000);
            }
          }
        }
      }
      else {
      }
    }
  }