A lazy way to do it would be to save the previously clicked node in a variable, and in the OnClick check if the selected node after clicking is equal to that variable. If the user selected another node it would return false, and of course if the user clicked something else it would deselect the node, once again making it false.

Dan