<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def find_video_file(rtdc_dataset):
 """Tries to find a video file that belongs to an RTDC dataset Returns None if no video file is found. """

        video = None
        if rtdc_dataset._fdir.exists():
            # Cell images (video)
            videos = [v.name for v in rtdc_dataset._fdir.rglob("*.avi")]
            # Filter videos according to measurement number
            meas_id = rtdc_dataset._mid
            videos = [v for v in videos if v.split("_")[0] == meas_id]
            videos.sort()
            if len(videos) != 0:
                # Defaults to first avi file
                video = videos[0]
                # g/q video file names. q comes first.
                for v in videos:
                    if v.endswith("imag.avi"):
                        video = v
                        break
                    # add this here, because fRT-DC measurements also contain
                    # videos ..._proc.avi
                    elif v.endswith("imaq.avi"):
                        video = v
                        break
        if video is None:
            return None
        else:
            return rtdc_dataset._fdir / video