I will just answer to you publicly so the other forum users can see my answer if they bump into this thread.
Thanks for this explanation. I initially thought that you are referring to generating reports via ReportService. For the
InventoryService, the filter "
parentId = 0" would only return one ad unit per DFP network, and this ad unit is the root/network ad unit. If what you are referring by top level ad units are the next level ad units after the root ad unit, then after that query (where parentId = 0) that gets the root ad unit, you need to get the
ad unit ID of this root ad unit and then use it in your next query as filter for the parentId field. This will then return the child ad units of your root ad unit.
For the network code that you provided privately, I was able to get the root ad unit by filtering by parentId = 0. However, for the next level of ad units, I only got one ad unit using the ad unit ID of the root ad unit as parentId filter. After that, I then used the ad unit ID of the previous returned data as parentId filter and it returned 64 ad units which are your actual top level ad units (except for root ad unit) based on the DFP UI. So you can also emulate this on your end (three queries, instead of two queries) to get the top level ad units in this specific DFP network.
Let me know if you have further clarifications.