Fixed an issue which caused FindCommonAncestor to use too much memory.