Check out the replaceNode.mel script. Located here:
.../MayaX.X/scripts/others/replaceNode.melThere's also the
nodeCast
command.