It's a shame EngineChannel doesn't know its channel number. Otherwise you could skip the search. 

You should call getMaster() outside of the loop and if it is NULL, don't loop at all.