linked lists and trees in R