def METHOD_NAME(pkg_info):
    item = {"installed_size": 0}
    for pkg_info_attr, item_attr in (("identifier", "packageid"),
                                     ("version", "version")):
        try:
            val = pkg_info.attrib[pkg_info_attr]
        except KeyError:
            raise AttachmentError("PackageInfo w/o {}".format(pkg_info_attr))
        else:
            if not val:
                raise AttachmentError(f"PackageInfo {pkg_info_attr} empty")
            item[item_attr] = val
    for payload in pkg_info.findall("payload"):
        try:
            item["installed_size"] += int(payload.attrib["installKBytes"])
        except KeyError:
            raise AttachmentError("pkg-info > payload w/o installKBytes")
    return item