[TRE] Simplify code with range-based loops and std::find.