public CycList treeConstants() {
    final CycList constants = new CycList();
    final Stack stack = new Stack();
    stack.push(this);
    while (!stack.empty()) {
      final Object obj = stack.pop();
      if (obj instanceof CycConstant) {
        constants.add(obj);
      } else if (obj instanceof CycAssertion) {
        stack.push(((CycAssertion) obj).getMt());
        pushTreeConstantElements(((CycAssertion) obj).getFormula(), stack);
      } else if (obj instanceof CycNart) {
        stack.push(((CycNart) obj).getFunctor());
        pushTreeConstantElements(((CycNart) obj).getArguments(), stack);
      } else if (obj instanceof CycList) {
        pushTreeConstantElements(((CycList) obj), stack);
      }
    }
    return constants;
  }