<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_d2ifile(flist,detector):
 """ Search a list of files for one that matches the detector specified. """

    d2ifile = None
    for f in flist:
        fdet = fits.getval(f, 'detector', memmap=False)
        if fdet == detector:
            d2ifile = f
    return d2ifile