Changed find_common_ancestor with Andrew's code