Properly handle and skip empty intermediary flows

Instead of linking nodes which have elements to
predecessors which do not we should search backwards
through the prior predecessors and link to one that
does have nodes; this ensures that we do not create
bad workflows when empty flows are injected.

Fixes bug 1392650

Change-Id: Ic362ef3400f9c77e60ed07b0097e3427b999d1cd
Merge "Properly handle and skip empty intermediary flows"