Is there way to get the hierarchy between branches?

i’m trying to find a way to get the hierarchy between branches using the gitlab api, for example i want to know what are all the branches that came from master and if possible their children and so on. is there a way to do so ? or at least something that can get me close to this ?