Added function to find immediate children of a node
Factored out event handler for each node