creates a linked list of all the nodes at each depth