Dictionary / Vocabulary / 時と場合によって
ときとばあいによって
should time and circumstances permit
時と場合によっては次善を選ばなくてはならぬ。
You must choose the second-best policy according to the circumstances.