SetBranchStatus - third flag?

auto child = tree->GetBranch(unwanted_branch_name);
auto parent = child->GetMother()->GetSubBranch(child);
parent->GetListOfBranches()->Remove(child);
parent->GetListOfBranches()->Compress();

Note that if you have a chain, you need to execute this at each file boundary, so you would also need attach a notify action to the chain. (See ROOT: TNotifyLink< Type > Class Template Reference and See also the doc of TChain::LoadTree for an explanation on the usage of the notify object by the chain and TTreeReader TChain notify on change of file - #5 by zhubacek)