This does a fairly crappy job of detecting joints

but a good job of merging them together.

ugh, my python style is terrible