Inverts a ?: ternary expression and adds/removes the necessary branches.