Block indices in different versions

Good morning.
I found a function to get the block indices of case.foam, the problem is that this function was created for paraview-5.8.0. When i run it with that version, it works propertly, but with the latest version (5.11.0), does not work.
Do you know if i have to add any command or import something?. There is any function already done that extract the indices of a case.foam?
Thank you so much.
Rafa

def get_block_indices(composite_data_information, index=0):
    """
    Source: https://discourse.paraview.org/t/get-block-name-and-id-from-multiblock-dataset/4014/2
    :param composite_data_information:
    :param index:
    :return:
    """
    localDict = {}

    if composite_data_information.GetDataIsMultiPiece():
        index += composite_data_information.GetNumberOfChildren()
    else:
        if composite_data_information.GetDataIsComposite():
            for i in range(composite_data_information.GetNumberOfChildren()):
                index += 1
                _blockName = composite_data_information.GetName(i)
                localDict[_blockName] = index
                leafDict, index = get_block_indices(
                    composite_data_information.GetDataInformation(i).GetCompositeDataInformation(), index)
                localDict.update(leafDict)

    return localDict, index