Removing a command tree during job?

[ Note that there is no category for UI command management ]

Our simulation framework defines a fairly complex set of sources with its own UI commands. The basic primary generator is built on top of G4ParticleGun. That means that all the /gun/… commands are exposed, but don’t work properly (since our framework does it’s own setting of position, direction, etc.).

Is there an easy (or at least safe) way to remove a whole command tree? I’d like to do something like

G4UImanager* uiman = G4UImanager::GetUIpointer();
G4UIcommandTree* uitop = uiman->GetTree();
G4UIcommand* guns = uitop->FindPath("/gun/");
uitop->RemoveCommand(guns);

This doesn’t work, because FindPath() only works on full commands, not on directories. Is there a way to remote the whole set of commands, or do I need to hardcode and remove each individual /gun/... command?