added code for making tree from arry