Improve commonAncestor by using a single loop instead of two shift()s

See http://jsperf.com/two-array-shift-vs-for

This optimization improves the commonAncestor() function a lot, since this is called a huge bunch of times, this is a viable change.

The signature and behaviour is identical