from pathlib import Path


def _get_file_dict(fp,fname):
    """ Find an image matching fname in the collection
    
    This function searches files in a FilePattern object to find the image dictionary
    that matches the file name, fname.

    Inputs:
        fp - A FilePattern object
        fname - The name of the file to find in fp
    Outputs:
        current_image - The image dictionary matching fname, None if no matches found
    """
    current_image = None
    for f in fp.iterate():
        if Path(f['file']).name == fname:
            current_image = f
            break
    
    return current_image