def join_overlapping_path(p1, p2):
    sm = difflib.SequenceMatcher(None, p1, p2)
p1i, p2i, size = sm.get_matching_blocks()[0]
if not p1i or not p2i:
    None
p1, p2 = (p1, p2) if p2i == 0 else (p2, p1)
size = sm.get_matching_blocks()[0].size
return p1 + p2[size:]
Is there any smart way to combine overlapping paths in python?