implement insertInTree and add method