Aharon,
I wouldn't suggest that approach. trying to invoke that plugin's code, as that chunk of code is buried down a few levels.
Rather, I meant to illustrate the steps: establish the two courses, parent and child, get an instance of the metacourse enrol plugin, and associate the child to the parent using that instance of the plugin.
Regards,
FW