For subdivision specifically, there is a special “Unsubdivide” function.
But keep in mind that it only works well if you didn’t make changes to the geometry besides maybe pulling it about, so no new loop cuts or extrusions etc.
If you don’t care much about topology or made changes to the mesh you can use Decimate instead, this will give you a bit more control over how much you want to simplify your mesh. It should probably be fine for trees, rocks and alike but it’s not a great idea to use it for characters etc. unless you really have to.
Most modifiers cannot be undone after they’re applied though so be careful with what you apply. The whole point of using modifiers is that you’re working non-destructively and can always back out of them. When you apply a modifier you make the changes permanent in most cases and if you don’t undo immediately or run out of undo steps your only option will be manual cleanup by selecting verts/edges and dissolving them.