It’s up to you how you handle classes. If you do not cast to a specific class, you’ll get hits on everything - all actors.
The cast here serves only as a filter so we do not accidently grab something undesired. There are many ways to filter what you need - taking advantage of the cast failing seemed the most straightforward here.
You select an object, check if it’s of a specific class via a cast. If it succeeds - the object is of the desired type, and vice versa.