Yes, I attempted to replicate that functionality in the last section with my package download script - was all going very well until I found that some packages were split in to many smaller packages with those branching dependencies you mentioned. I couldn’t find a reliable database for all that information and instead resorted to scraping this webpage.
Could use a proper database really.