As the points in the figure, a 'X' may map two "Y" value and a 'Y' may map two "X" value.
When fitting a curve with these points, it should ensure that first-order derivative and
second-order derivative can be calculated.
Edit: Both Floris and pancake gave a correct answer,thank you for both.
Rather than fitting 'y' as a function of 'x', you need to fit separately:
where 't' is the intrinsic coordinate of a spline (or other curve fit, eg. polynomial).
I assume in the picture you know the order of the points - it's not just a jumble of unsorted points? So first of all, you could calculate the distance between each successive point, and use the cumulative distance as your 't' parameter. Then fit splines to the 'x' and 'y' coordinates as functions of t.