Generalized common ancestor detection for 3+ merges.

Also only count the common ancestors to simplify the ancestry slice