def _generate_and_store_mold_id_map(self, template_map, molds):
        """
        Not a pure generator expression as this has the side effect of
        storing the resulting id and map it into a local dict.  Produces
        a list of all valid mold_ids from the input template_keys.

        Internal function; NOT meant to be used outside of this class.
        """

        name = self.req_tmpl_name
        for key in sorted(template_map.keys(), reverse=True):
            if len(key.split('/')) == 3 and key.endswith(name):
                mold_id = key[len(self.text_prefix):-len(name) - 1]
                molds[mold_id] = template_map[key][:-len(name) - 1]
                yield mold_id
Not a pure generator expression as this has the side effect of
        storing the resulting id and map it into a local dict.  Produces
        a list of all valid mold_ids from the input template_keys.

        Internal function; NOT meant to be used outside of this class.