changed get_node method to cope with trees as leaves