Create generalized compareFrames() function.