How to use GSPath.removeNodeAtIndex_() correctly

Hello, I have a question regarding GSPath.removeNodeAtIndex_(). I am trying to use the method in order to remove duplicate nodes like this:

However, when I run the method, the following happens:

Any reason the offcurve nodes need to be deleted as well? I would like to keep them. Same happens if I do GSPath.nodes.remove(node).

You need to remove the second of the two nodes. That is a line node that is a zero length line segments. removing it doesn’t change the path structure. the first of the two nodes might be a curve node and removing that makes the preceding segment a line (the next node is a line).