Optimizing 'instanceof' when comparing to extension interfaces