Collapsed ends, occupied paths and paths into one function.
Again checks that a move does not put the king in check.