I thought about that, but object names aren't guaranteed to be unique. It's possible for two guns that have children named "foregrip" or "clip" for example. I ended up settling on patching local IDs based on an offset from the root of the hierarchy. That way my local ID links are still meaningful as long as I know the ID of the hierarchy's root.
You can hash the whole hierarchy string eg.
object: "starship 1/wing/leftgun", "starship 2/wing/leftgun", "starship 3/wing/leftgun"