Adding polyData block from vtp elements to vtkMultiBlockDataSet

Hello. I am using python with the vtk library. I need to add to vtkMultiBlockDataSet a block consisting of at least one separate polyData (vtp) element. And then I want to write the result using the vtkXMLMultiBlockDataWriter class.
So it should look like this in the vtm file:

<?xml version='1.0'?>
<VTKFile type='vtkMultiBlockDataSet' version='1.0' byte_order='LittleEndian' header_type='UInt64'>
    <DataSet name='internal' file='result/internal.vtu' />
    <Block name='boundary'>
      <DataSet name='wall' file='result/boundary/wall.vtp' />
      <DataSet name='outlet' file='result/boundary/outlet.vtp' />
      <DataSet name='inlet' file='result/boundary/inlet.vtp' />

However, I couldn’t find how to combine multiple vtp files and add them as a single block to the vtkMultiBlockDataSet class object.
This is currently done as follows:

from vtk import *


result = vtkMultiBlockDataSet()

result.SetBlock(0, myVtkUnstructuredGrid)
result.SetBlock(1, myVtkPolyData1)
result.SetBlock(2, myVtkPolyData2)
result.SetBlock(3, myVtkPolyData3)

writer = vtkXMLMultiBlockDataWriter()

And this produces the following result in the vtm file:

<?xml version="1.0"?>
<VTKFile type="vtkMultiBlockDataSet" version="1.0" byte_order="LittleEndian" header_type="UInt32" compressor="vtkZLibDataCompressor">
    <DataSet index="0" file="result/result_0.vtu"/>
    <DataSet index="1" file="result/result_1.vtp"/>
    <DataSet index="2" file="result/result_2.vtp"/>
    <DataSet index="3" file="result/result_3.vtp"/>

I tried using vtkMultiBlockDataGroupFilter, vtkMultiBlockMergeFilter, and vtkPartitionedDataSetCollection, but all to no avail.
Could you please advise me on the best way to implement this?

The problem was solved on its own (version vtk - 9.3.0). The solution is:

    # myVtkPolyData - list of polyData objects
    result = vtkMultiBlockDataSet()
    boundaryDataSet = vtkMultiBlockDataSet()
    polyDataSize = len(myVtkPolyData)
    for i in range(0, polyDataSize):
        boundaryDataSet.SetBlock(i, myVtkPolyData[i])
    result.SetBlock(0, myVtkUnstructuredGrid)
    result.SetBlock(1, boundaryDataSet )

To change/add DataSets names, you must perform the operations:

    it = result.NewIterator()
    idx = 0
    while not it.IsDoneWithTraversal():
        if idx == 0:
            it.GetCurrentMetaData().Set(vtkMultiBlockDataSet.NAME(), "internal")
        elif idx == 1:
            it.GetCurrentMetaData().Set(vtkMultiBlockDataSet.NAME(), "boundary")
            it.GetCurrentMetaData().Set(vtkMultiBlockDataSet.NAME(), boundaryNames[idx - 2])
        idx += 1

The result will be as follows:

<?xml version='1.0' encoding='UTF-8'?>
<VTKFile type="vtkMultiBlockDataSet" version="1.0" byte_order="LittleEndian" header_type="UInt32" compressor="vtkZLibDataCompressor">
    <DataSet index="0" name="internal" file="result/result_0.vtu" />
    <Block name="boundary" index="1">
      <DataSet index="0" name="boundaryName1" file="result/result_1.vtp" />
      <DataSet index="1" name="boundaryName2" file="result/result_2.vtp" />
      <DataSet index="2" name="boundaryName3" file="result/result_3.vtp" />