Given a list which looks like this:
[(1, 'a'), (1, 'b'), (2, 'c'), (1, 'd')]
I want to join the consecutive tuples inside the list if they have same first value, so the result looks like following:
[(1, 'ab'), (2, 'c'), (1, 'd')]
Should only join if both are next to each other.
If key is None like below it should be merged to previous item.
[(1, 'a'), (1, 'b'), (None, 'e'), (2, 'c'), (1, 'd')]
result should be
[(1, 'abe'), (2, 'c'), (1, 'd')]