该时间状语从句省略了 主语 和 be 动词,即:… when in trouble = … when (he was) in trouble;
此类现象是中学英语语法中非常常见常考的项目:状语从句的省略。
其条件有二,一是状语从句的主语是 it 或者 状语从句的主语和主句的主语相同,二是状语从句的谓语含有 be 动词。
如果这两个条件同时都符合,则可以把该状语从句的主语和 be 动词一起省略。
如:I'll go there with you if (it is) possible/necessary.
I won't attend the party if (I am) not invited.