LCS of a tree python