Ah ok, there are ways you can make it more general.
If you're always specifying an area, you can just walk to random points in the area and check for trees. If your area is x1=3096 y1=3210 x2=3142 y2=3220, you could just generate a random X to walk to between 3096 and 3142, and a random Y between 3210 and 3220.
If you're not specifying an area, you could chuck in a parameter for the task to say "You can stray this far from the starting point", and then you could walk randomly anywhere in that area.
Hardcoding is always going to be faster, but yeah, if you're trying to be more general this isn't a great solution.