Inverts an if condition and adds/removes the necessary branches.