Pack external data ignores multiple files with same name from different paths

Packing external data into blend files switches all the textures nodes that use different textures, with the same name, but different path to only use one of the textures resulting in materials that have wrong textures assingned to them.

Example of texture setup resulting in issue:

/asset_a/bake_ao.tga
/asset_b/bake_ao.tga

Packing the textures into a blend and then unpacking them means that asset B now shares textures with asset A. And the textures from asset B aren’t included at all.

Is there any workaround or script to fix this issue? I realize proper file managment is the answer, but I have multiple old project I need to move with packing, each containing hundreds of 4k and 8k textures in bit more involved node setups and it isn’t really feasible to go through all of them manually by fixing individual textures.