public static object Evaluate(FormulaTree formula) { if (formula == null) return null; return formula.IsNumber() ? (object)formula.EvaluateNumber() : formula.EvaluateLogic(); }