Lets say there are two lists
L1=[['A', ['C', ['B', ['D', 0]]]],
[['A', ['D', ['K', ['C', ['E', 0]]]]],
[['A', ['C', ['B', ['M', 0]]]]]
and
L2=[['A', ['C', ['B', ['K', 0]]]],
[['A', ['C', ['B', ['B', ['E', 0]]]]],
[['A', ['D', ['K', ['F', 0]]]]]
Then the output should return all the sub-paths with longest common path. For example:
Since 'A', 'C', 'B' is common L1 and L2; output should be:
[['A', ['C', ['B', ['D', 0]]]],
[['A', ['C', ['B', ['M', 0]]]],
[['A', ['C', ['B', ['K', 0]]]],
[['A', ['C', ['B', ['B', ['E', 0]]]]]
. Also, 'A', 'D', 'K' is also common for one time in L1 and L2; the output whould be:
[['A', ['D', ['K', ['C', ['E', 0]]]]],
[['A', ['D', ['K', ['F', 0]]]]]
I tried :
[i for i in L1 if i in L2]
but it will give the output of all the common paths till the leaf (end).