I'm using the eikon API to retrieve the subsidiary data from the refinitiv. I'm able to retrieve subsidiary information for level 1 subsidiaries only. I'm unable to retrieve the level2 or upto level n subsidiaries. I want my results to be in the form of dictionary. In short for a company tree, the result of the function should return dictionary.
For example, the output of retrieve_subsidiaries(['5000065135', '4298158727']) should be ...
{
    '5000065135': ['5036778064', '5043368391', '5076086756', '5046707557', '', '5036778506', '5082358234']
    '4298158727': []
}.
I have tried this. But unfortunately, the run time is also very high as there are multiple API requests being done.
I have tried this at my end. Is there any other way to address this issue?
def retrieve_subsidiaries(tcodes):
    subs_parameters = {
        'SDate': 0,
        'EDate': -3,
        'Curn': 'JPY',
        'Scale': 6,  
        'ReportType': 'Latest',       # Latest, Prelim, Final, All
        'ReportingState': 'Rsdt',    # Orig, Rsdt, All
        'FRQ': 'FY',
    }
    subs_fields = [
        'TR.OrganizationID',
        'TR.RelatedOrgId',
        'TR.RelatedOrgType',
    ]
    try: # Main part of the code
        display(tcodes)
        subs, err = ek.get_data(tcodes, subs_fields, subs_parameters)
        display(subs)
    except Exception as e:
        display(e)
        sys.exit(1)
    result = {}
    tcodes = [int(item) for item in tcodes_list]
    for tcode in tcodes:
        subsidiaries = subs[(subs['Instrument'] == tcode) & (subs['Related Org Type'] == 'Subsidiary')]['Related OrgId'].tolist()
        result[tcode] = [sub for sub in subsidiaries if sub]  
    return result, subs