Universal Robots+

TreeStructureException: Attempted node removal not allowed - Error for IfNode

my URCap code removes child nodes below the Cap root. It works for most nodes but I get the following error for an IfNode:
com.ur.urcap.api.domain.program.structure.TreeStructureException: Attempted node removal not allowed.

Any idea why the IfNode throws the error and how to fix it?