Selecting parent nodes

I am working on a large tree, the way i need it to work, is that if a parent node has been selected, only it is returned and none of its children. Is there a way to accomplish that ?



Ex



Vegetables (Userdata: vg-100)

|-------- Potato

|-------- Carrot

|-------- Eggplant



If the Vegetable branch is selected, i would only like to retrieve the userdata of Vegetables

The API of tree allows to get list of checked items, but it is not possible to “serialize only checked” items.

get list of checked
       var ids=tree.getAllChecked();
       ids=ids.split(",")
       for (var i=0; i<ids.length; i++)
          alert(tree.getUserData(ids[i],“somedata”))