Better common path prefix algorithm... by miles