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

See http://jsperf.com/two-array-shift-vs-for
Merge pull request #5 from DrRataplan/master

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