Remove duplicate positions from polylines.

For #898.
Is it cleaner to just return `undefined` if no duplicates were removed?