I have a well-formed tree that represents a mathematical expression. For example, given the string: \"1+2-3*4/5\", this gets parsed into:
\"1+2-3*4/5\"
subtr
This task can become quite complicated (besides the simplest transformation). Essentially this is what algebra software does all the time.
You can find a readable introduction how this is done (rule-based evaluation) e.g. for Mathematica.