Least Common Ancestor, written in Python