Generalized common ancestor detection for 3+ merges.

Also only count the common ancestors and inline the ancestry slice