fixed problem with root node not being highlighted; extracted a couple of functions