while (the stack is not empty) { pop a name off the stack search that directory for entries: -- if it is "." or ".." then SKIP it. (Guess this is what you're not doing.) -- if it is a directory, "push" or "unshift" the fully-qualified name onto the stack. -- if it is a file, process it, or stack it on another queue it to be processed soon. }