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'>
  <vtkMultiBlockDataSet>
    <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' />
    </Block>
  </vtkMultiBlockDataSet>
</VTKFile>

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.SetNumberOfBlocks(4)
result.SetBlock(0, myVtkUnstructuredGrid)
result.SetBlock(1, myVtkPolyData1)
result.SetBlock(2, myVtkPolyData2)
result.SetBlock(3, myVtkPolyData3)

writer = vtkXMLMultiBlockDataWriter()
writer.SetFileName("result.vtm")
writer.SetInputData(result)
writer.Write()

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">
  <vtkMultiBlockDataSet>
    <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"/>
  </vtkMultiBlockDataSet>
</VTKFile>

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()
    result.SetNumberOfBlocks(2)
    
    boundaryDataSet = vtkMultiBlockDataSet()
    polyDataSize = len(myVtkPolyData)
    
    boundaryDataSet.SetNumberOfBlocks(polyDataSize)
    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()
    it.SetVisitOnlyLeaves(False)
    it.SetSkipEmptyNodes(False)
    it.InitTraversal()
    
    idx = 0
    while not it.IsDoneWithTraversal():
        if idx == 0:
            it.GetCurrentMetaData().Set(vtkMultiBlockDataSet.NAME(), "internal")
        elif idx == 1:
            it.GetCurrentMetaData().Set(vtkMultiBlockDataSet.NAME(), "boundary")
        else:
            it.GetCurrentMetaData().Set(vtkMultiBlockDataSet.NAME(), boundaryNames[idx - 2])
        idx += 1
        it.GoToNextItem()

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">
  <vtkMultiBlockDataSet>
    <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" />
    </Block>
  </vtkMultiBlockDataSet>
</VTKFile>