Iterate directly over the filtered element collector. In general, there is no need to create a copy of it. Calling ToElements creates a copy, allocating space for that and wasting both memory and time. No need to cast either, foreach can do that automatically.