@@ -198,21 +198,26 @@ function _fusiontree_iterate(uncoupledsectors::NTuple{N}, coupled::I, out, lines
198
198
vertexiterN = c ⊗ dual (b)
199
199
outstateN = states[end ]
200
200
vertexstateN = states[end - 1 ]
201
+ n = vertices[end ]
201
202
while isnothing (rest)
202
- n = vertices[end ]
203
- n < Nsymbol (a, b, c) && return out, lines, (restvertices... , n + 1 ), states
204
- nextline = iterate (vertexiterN, vertexstateN)
205
- while isnothing (nextline)
206
- nextout = iterate (outiterN, outstateN)
207
- nextout === nothing && return nothing
208
- b, outstateN = nextout
209
- vertexiterN = c ⊗ dual (b)
210
- nextline = iterate (vertexiterN)
203
+ if n < Nsymbol (a, b, c)
204
+ n += 1
205
+ # reset the first part of the fusion tree
206
+ rest = _fusiontree_iterate (Base. front (uncoupledsectors), a)
207
+ else
208
+ nextline = iterate (vertexiterN, vertexstateN)
209
+ while isnothing (nextline)
210
+ nextout = iterate (outiterN, outstateN)
211
+ nextout === nothing && return nothing
212
+ b, outstateN = nextout
213
+ vertexiterN = c ⊗ dual (b)
214
+ nextline = iterate (vertexiterN)
215
+ end
216
+ a, vertexstateN = nextline
217
+ n = 1
218
+ rest = _fusiontree_iterate (Base. front (uncoupledsectors), a)
211
219
end
212
- a, vertexstateN = nextline
213
- rest = _fusiontree_iterate (Base. front (uncoupledsectors), a)
214
220
end
215
- n = 1
216
221
restout, restlines, restvertices, reststates = rest
217
222
out = (restout... , b)
218
223
lines = (restlines... , a)
0 commit comments