Getting treePrototype information from RayCasting collisions onto terrain?

I need to be able to look at a tree on a terrain and be able to get what type of tree it is (say, an Oak vs. a Pine). A ray cast from the camera seems to collide with the trees just fine, but only returns "terrain" as the collider touched. I'm not too concerned with the individual tree, merely its type, and the scene itself is static, so the terrain won't change during runtime right now.

In a nutshell, I need the get the specific treePrototype from a ray cast collision on the terrain.

I know the terrain API is murky, but is there a good way to do this? The scene itself has thousands of trees, so looping through every single treeinstance to find the tree I'm looking at isn't really feasible, nor is placing colliders by hand as separate objects.

It seems like I should be able to find out the original treePrototype prefab quickly if I'm raycasting to its capsule collider, but perhaps not - another possibility would be to look at texture data, if the terrain stores the tree data there along with ground info. Any suggestions?

The trees created by paint tool on terrain have no collision. You need to get the tree and add collider to make a prefab, then place them on terrain.

I know 1000 trees is a bit more, but at least Unity can automatically place right upon terrain height.

The approach I ended up using was actually creating the collider capsules on my own, using a script (shown by a coder with a similar problem) that looped through each of the treeInstances within terrainData and created a collider that matched the location on the existing terrain. You end up rebuilding some of the terrain information on your own this way, but it's far more accessible. Having a script that does this offline is practically a must, as it takes a few minutes to calculate. Once it's done, however, you'll have capsules you can add metadata to, and whose individual info can easily be read by a ray cast.