I've had another look at this.
A few debug outputs shows that the "error" arises when trying to remove
the node <KnuthNode at 734 4527603+682968-135942 line:10 prev:687
dem:11527.971465493918> while the list of active nodes contains
[
<KnuthNode at 734 4527603+682968-135942 line:10 prev:683
dem:11513.226030457132>,
<KnuthNode at 734 4527603+682968-135942 line:10 prev:687
dem:11527.971465493918>,
]
This removal, however, happens at the end of the algorithm, when the best
layout is chosen (just like Vincent pointed out), and in this situation a
node could be rightly be removed even if it's not the first one.
We could maybe add a boolean parameter to removeNode(), stating whether it
is allowed to remove the nodes out of order or not, and only the calls in
filterActiveNodes() would have it "true".
HTH
Luca