code: func (w *TreeWalker) Next() (name string, entry TreeEntry, err error) {
  	var obj *Tree
  	for {
  		current := len(w.stack) - 1
  		if current < 0 {
  			// Nothing left on the stack so we're finished
  			err = io.EOF
  			return
  		}
  
  		if current > maxTreeDepth {
  			// We're probably following bad data or some self-referencing tree
  			err = ErrMaxTreeDepth
  			return
  		}
  
  		entry, err = w.stack[current].Next()
  		if err == io.EOF {
  			// Finished with the current tree, move back up to the parent
  			w.stack = w.stack[:current]
  			w.base, _ = path.Split(w.base)
  			w.base = strings.TrimSuffix(w.base, "/")
  			continue
  		}
  
  		if err != nil {
  			return
  		}
  
  		if w.seen[entry.Hash] {
  			continue
  		}
  
  		if entry.Mode == filemode.Dir {
  			obj, err = GetTree(w.s, entry.Hash)
  		}
  
  		name = simpleJoin(w.base, entry.Name)
  
  		if err != nil {
  			err = io.EOF
  			return
  		}
  
  		break
  	}
  
  	if !w.recursive {
  		return
  	}
  
  	if obj != nil {
  		w.stack = append(w.stack, &treeEntryIter{obj, 0})
  		w.base = simpleJoin(w.base, entry.Name)
  	}
  
  	return
  }
docs: // Next returns the next object from the tree. Objects are returned in order
  // and subtrees are included. After the last object has been returned further
  // calls to Next() will return io.EOF.
  //
  // In the current implementation any objects which cannot be found in the
  // underlying repository will be skipped automatically. It is possible that this
  // may change in future versions.