Modified treewalker to return nodes