Precondition.checkMustNotBeNull(connections, "connections"); //$NON-NLS-1$
LinkedList<PortConnection> next = new LinkedList<PortConnection>();
next.add(start);
Set<PortConnection> results = Sets.create();
while (next.isEmpty() == false) {
PortConnection successor = next.removeFirst();
if (connections.contains(successor)) {
results.add(successor);
} else {
FlowElementInput nextInput = successor.getDownstream();
for (FlowElementOutput output : nextInput.getOwner().getOutputPorts()) {
next.addAll(output.getConnected());
}
}
}