Non-recursive Douglas-Peucker implementation