Figuring out components hierarchy when fetching from team library

In my Figma plugin, when I fetch components from the team library using fetch(${FIGMA_API_ENDPOINT}teams/${teamKey}/components)

I get a list of components from my library.

However, the components usually consist of many smaller components, which also consist of components. I want to know if there is a way to find out all the components and their hierarchies from the components in the team library.