Best way to replace a plugin

I have a list of plugins in a track and would like to know the best method for replacing a plugin at a specific index. Any tips?

then add the new plugin at whatever index is appropriate (maybe the index that you just removed).

Is that what you need?

Thanks @dave96. deleteFromParent() is what I needed.