Retrieving path to item that is visible from outside the crate

Hi everyone I’m working on a Rust project and I’m doing static analysis of a given crate using rustc internals by using the after_analysis callback. I want for a function (I know its DefId) that is part of the crate’s API, to get the full path of ancestors which path could be used to call this function from outside, i.e., from a user of the crate. I was looking at the visibilities of defined items in rustc but I got really confused. Any help is appreciated!

Update: I have figured out a way to do that by using the effective_visibilities map.