Python node that replaces itself in the editor with a group? This might be a bit of a weird one, but I'm looking to write a Python node that will, upon a user's input of a folder path, replace itself with a node group that contains itself and other nodes based on the contents of the folder.  I'm trying to perform this transformation:

MyNode


User inputs folder path

MyNodeGroup:
    MyNode
    Other Nodes


Is this possible?

I imagine I'd have to create and instance the group immediately, then move my node into it along with any other new nodes that I need.  If it's not possible to move an existing node into a group, could I create an identical node and then delete the old?

Any advice on this problem is greatly appreciated!

Edit: Or, if groups are not the most appropriate mechanism for this, is it possible to maintain other nodes inside my node internally?
You can probably write a script that generates such node setup after being given a file path. Use the single selected node to read its inputs and outputs, then delete it by the script and attach generated nodes' IO to what you read.