Analysis list to tree algorithm