but surely climbing at best rate would give you the best chance of clearing the trees wouldn't it?
quite so.
Not quite...
Best climb ANGLE will give you the most clearance over a close-in obstacle.
However, especially for a relatively inexperienced pilot, climbing at best angle speed (Vx) will give less stall margin in case of engine failure than will best rate (Vy). Unless the trees are VERY close and your clearance above them VERY small (as in too scary to really want to try), Vy will give you an adequate margin overall.
Remember, crashing into trees straight ahead is preferable to stalling and crashing into the ground in a vain attempt to return to the runway from too low an altitude.