fires the moment you attempt to close the tree branch
some.attachEvent("onBeforeClose", function(){ //... some code here ... });