Tree component: collapsing and extending

Hello,

I am using a tree component containing groups of checkboxes.

I would like to extend and collapse these groups of checkboxes on a JS event (the same effect as when someone click on + or - ) but I don't know how to express that.

Thanks for your help

Florent