Solves equations in tree form