def find_joined_path(p1, p2):
    for i in range(len(p1)):
        if p1[i:] == p2[:len(p1) - i]:
            return p1[:i] + p2
print(find_joined_path(p1, p2))
Is there any smart way to combine overlapping paths in python?