transform component/dom list nodes into a tree