JOSM: Merging lots of overlapping nodes?

I am trying create a process to import some data I have created to OpenStreetMap.

Right now I am using the ImportVec plugin to import SVG files. My files are made up of lots of individual lines with overlapping endpoints. When I import into JOSM each line is therefore made into a separate way. The node at the end of each way overlaps with the end node of an adjacent way.

I want to figure out if there is an easy way in JOSM to merge all overlapping nodes selected. The ‘Merge Nodes’ tool works but only when merging 2 overlapping nodes together. If I have a 1000 nodes, it would be a waste of time to do each one separately.

It’s probably easily doable in a script, but I am not familiar with using JOSM’s interface or writing in JavaScript. If I could merge all overlapping nodes, where exactly 2 nodes overlap that wouldn’t cause any problems. Trying to join 3 or more overlapping end nodes wouldn’t work since it would join 3 ways together.

Just wondering if anyone has any advice?

Validating the dataset in JOSM gives you warnings about nodes on the same position. Click fix for this type of warning should work. However this only merges the nodes, not the single way segments.