remove recursive behaviour of SequentialBFS