JBPM-4029 - Improve gateway handling when inside a loop