Creates a tree by scanning the index file. The method handles recursive creation of trees for subdirectories and adds them to the parent tree.