AddNewNodeByClass accepts a name that is set to the node, but sets it exactly as specified. If you’d like to generate a unique name then utilize slicer.mrmlScene.GenerateUniqueName("…") as part of the string you pass into AddNewNodeByClass. If any documentation is incorrect or unclear, then I’m sure improvements to the API documentation would be welcome.
/// \note Instead of calling SetName() after creating the node, prefer
/// passing \a nodeBaseName, indeed the method AddNode() ensures that the
/// final node name is unique in the scene by appending a suffix if needed.
It may mean that the unique name is handled by ‘AddNode’, itself called by ‘AddNewNodeByClass’.