that's exactly what I meant with 
> if you want you can simplify this by calling polpetta_root just once (removing the one in the root definition also),  after these splice are done.

Right now it was eventually setting the root wrong a couple of time before fixing it, after the ifs the root is always correct, and that's why I told you that it works  just fine.

Anyway I'll make the couple of changes highlighted and then ping you again :)