def METHOD_NAME(self, mat):
    mat_doc = self.materials.query_one(
        {self.materials.key: mat},
        [
            self.materials.key,
            "structure",
            "task_types",
            "run_types",
            "last_updated",
        ],
    )
    task_types = mat_doc["task_types"].items()
    potential_task_ids = []
    for task_id, task_type in task_types:
        if task_type == "Optic":
            potential_task_ids.append(task_id)
    final_docs = []
    for task_id in potential_task_ids:
        task_query = self.tasks.query_one(
            properties=[
                "orig_inputs.kpoints",
                "orig_inputs.poscar.structure",
                "input.parameters",
                "input.structure",
                "output.dielectric.energy",
                "output.dielectric.real",
                "output.dielectric.imag",
                "output.optical_absorption_coeff",
                "output.bandgap",
            ],
            criteria={self.tasks.key: task_id},
        )
        if task_query["output"]["optical_absorption_coeff"] is not None:
            try:
                structure = task_query["orig_inputs"]["poscar"]["structure"]
            except KeyError:
                structure = task_query["input"]["structure"]
            if (
                task_query["orig_inputs"]["kpoints"]["generation_style"]
                == "Monkhorst"
                or task_query["orig_inputs"]["kpoints"]["generation_style"]
                == "Gamma"
            ):
                nkpoints = np.prod(
                    task_query["orig_inputs"]["kpoints"]["kpoints"][0], axis=0
                )
            else:
                nkpoints = task_query["orig_inputs"]["kpoints"]["nkpoints"]
            lu_dt = mat_doc["last_updated"]
            final_docs.append(
                {
                    "task_id": task_id,
                    "nkpoints": int(nkpoints),
                    "energies": task_query["output"]["dielectric"]["energy"],
                    "real_dielectric": task_query["output"]["dielectric"]["real"],
                    "imag_dielectric": task_query["output"]["dielectric"]["imag"],
                    "optical_absorption_coeff": task_query["output"][
                        "optical_absorption_coeff"
                    ],
                    "bandgap": task_query["output"]["bandgap"],
                    "structure": structure,
                    "updated_on": lu_dt,
                    self.materials.key: mat_doc[self.materials.key],
                }
            )
    if len(final_docs) > 0:
        sorted_final_docs = sorted(
            final_docs,
            key=lambda entry: (
                entry["nkpoints"],
                entry["updated_on"],
            ),
            reverse=True,
        )
        return sorted_final_docs[0]
    else:
        return None