How to get an existing Part object and its Document interface in SHAPER TUI?

Hello,

I am working with SALOME 9.15.0 SHAPER module and trying to automate the creation of edge/solid groups using a Python TUI script.

When I record a macro using “Dump Study”, creating a new part and getting its document is documented as follows:

partSet = model.moduleDocument()
Part_2 = model.addPart(partSet)
Part_2_doc = Part_2.document()

This returns a PartSetAPI_Part object to the variable Part_2, allowing me to use .document() to get the ModelAPI_Document context required for model.addGroup().

My Question:
If a Part named "PipeForest" already exists in the Object Browser, how can I retrieve this existing Part object into a Python variable as a PartSetAPI_Part instance so that I can call the .document() method?

Here is the Python script I tried to run on the existing part:

import salome
salome.salome_init()

from SketchAPI import *
from salome.shaper import model

def create_ogrid_groups_by_indices(part_selection, pipe_name, solid_indices):
    """
    Automatically generate O-Grid mesh groups from Partition_1_1 within the specified Part.
    part_selection : Selection object of the target Part (model.selection("PART", ...))
    pipe_name      : Name of the group to be created (e.g., "CoolantPipeFlexA")
    solid_indices  : List of index numbers for the 5 hexahedral cells
    """
    model.begin()

    # Get the name and selection object of the parent Part
    Part_str_name =  part_selection.name()
    Part_doc      = model.selection("PART", Part_str_name)
    #partSet       = model.moduleDocument()


    # Create the solidHexa group
    solid_selections = [model.selection("SOLID", f"{Part_str_name}/Partition_1_1_{idx}") for idx in solid_indices]
    solid_hexa_group = model.addGroup(Part_doc, "Solids", solid_selections, True)
    solid_hexa_group.setName(f"{pipe_name}_solidHexa")
    solid_hexa_group.result().setName(f"{pipe_name}_solidHexa")
    model.do()

    # Create the edgeAll group
    edge_selections = [model.selection("EDGE", f"{Part_str_name}/Partition_1_1_{idx}") for idx in solid_indices]
    edge_all_group = model.addGroup(Part_doc, "Edges", edge_selections, True)
    edge_all_group.setName(f"{pipe_name}_edgeAll")
    edge_all_group.result().setName(f"{pipe_name}_edgeAll")
    model.do()

    model.end()
    print(f"Success: Automatically generated group structures for {pipe_name} inside [{Part_str_name}].")

# ==========================================
#   User Settings: Specify the target Part object
# ==========================================
# 
target_part = model.selection("PART", "PipeForest")

pipes_definition = {
    "CoolantPipeFlexA": [3, 4, 5, 6, 7],
    "CoolantPipeTeeC" : [18, 19, 20, 21, 22]
}

# Batch execution of the macro
for pipe_name, indices in pipes_definition.items():
    create_ogrid_groups_by_indices(target_part, pipe_name, indices)

When running this, I get the following error;

>>> exec(compile(open('C:/SALOME-9.15.0/Group_OGridPipeInShaper.py', 'rb').read(), 'C:/SALOME-9.15.0/Group_OGridPipeInShaper.py', 'exec'))
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "C:/SALOME-9.15.0/Group_OGridPipeInShaper.py", line 52, in <module>
    create_ogrid_groups_by_indices(target_part, pipe_name, indices)
  File "C:/SALOME-9.15.0/Group_OGridPipeInShaper.py", line 24, in create_ogrid_groups_by_indices
    solid_hexa_group = model.addGroup(Part_doc, "Solids", solid_selections, True)
  File "C:\SALOME-9.15.0\W64\SHAPER\lib\python3.9\site-packages\salome\CollectionAPI.py", line 918, in addGroup
    return _CollectionAPI.addGroup(*args)
TypeError: Wrong number or type of arguments for overloaded function 'addGroup'.
  Possible C/C++ prototypes are:
    addGroup(std::shared_ptr< ModelAPI_Document > const &,std::list< ModelHighAPI_Selection,std::allocator< ModelHighAPI_Selection > > const &,bool const)
    addGroup(std::shared_ptr< ModelAPI_Document > const &,std::list< ModelHighAPI_Selection,std::allocator< ModelHighAPI_Selection > > const &)
    addGroup(std::shared_ptr< ModelAPI_Document > const &,std::string const &,std::list< ModelHighAPI_Selection,std::allocator< ModelHighAPI_Selection > > const &,bool const)
    addGroup(std::shared_ptr< ModelAPI_Document > const &,std::string const &,std::list< ModelHighAPI_Selection,std::allocator< ModelHighAPI_Selection > > const &)

Is there a specific API function in salome.shaper.model to get or cast an existing feature by its name/string into a PartSetAPI_Part interface?

Any advice or code snippets would be greatly appreciated.