Culling duplicate points problem

I can’t get my head around the following problem:

I have a polysurface. I intersect a couple of planes on world z-axis to get curves on the polysurface. I then want to divide each curve by length. However, since sometimes two lines have the same start/end points, I used this code* which works fine sorting

        for (int i = 0; i < tempPoints.Count - 1; i++)
            Point3d pt0 = tempPoints[i];
            Point3d pt1 = tempPoints[i + 1];
            double dist = pt0.DistanceTo(pt1);
            if (dist > this.Doc.ModelAbsoluteTolerance)

tempPoints are all points, pointsPerLevel should be the culled list of unique points.
However, I get this as a result:

As you can see, on some curves some points get culled while one similiar curves, they don’t. Also, the end points should be included as they are at the correct distance from the last point.
Removing above code, I get the correct points but also duplicate points at the start/end of curves.

Ignore every second line, I’m not dividing them currently.

original code altered: Delete duplicate points on Nurbs curve