'Get the item\'s sprite
If version is not given, use the latest version.'

def sprite(self, version=None):

    identifier = self.identifier
    if identifier.startswith(('tm', 'hm')):
        try:
            int(identifier[2:])
        except ValueError:
            pass
        else:
            machines = self.item.machines
            if version:
                try:
                    machine = [m for m in machines if (m.version_group == version.version_group)][0]
                except IndexError:
                    raise ValueError(("%s    doesn't    exist    in    %s" % (identifier, version.identifier)))
            else:
                machine = machines[(-1)]
            type_identifier = machine.move.type.identifier
            identifier = ((identifier[:2] + '-') + type_identifier)
    elif identifier.startswith('data-card-'):
        try:
            int(identifier[10:])
        except ValueError:
            pass
        else:
            identifier = 'data-card'
    if (version is not None):
        generation_id = version.generation.id
        if ((generation_id <= 3) and (identifier == 'dowsing-mchn')):
            identifier = 'itemfinder'
        try:
            gen = ('gen%s' % generation_id)
            return self.from_path_elements([gen], identifier, '.png')
        except ValueError:
            pass
    return self.from_path_elements([], identifier, '.png', surely_exists=True)
