functionality of adding items to a tree