A different approach, with a flexible handleNode function.