del remaining[remaining.index(start)]
possibles = [x for x in remaining if x[:1] == start[-1:]]
maxchain = []
for c in possibles:
    l = chain(c, remaining)
if len(l) > len(maxchain):
    maxchain = l
return [start] + maxchain
Longest chain of elements from list in Python