Filter mesh

Recently I encountered a problem, I want to reduce the number of faces of the mesh by the rhino command “reducemesh”, so that it can reduce the rendering pressure in unity 3D.
However, by selecting all the mesh faces to reduce, as the number of reductions increases, this will cause some meshes that have been reduced to the maximum extent to break. I think there are some ways to automatically omit the frame when selecting the mesh. These have been reduced to the maximum extent of the mesh.
Not long ago, I learned that rhino has grasshopper that can be used to write scripts. I wonder if it can be implemented by scripting.
(ps: my English is not very good, sorry)

Try with Blender