Skip to content

Instantly share code, notes, and snippets.

forEachIterativeStack(callback) {
const stack = [];
let i = 0;
let node = this._root;
while (node || stack.length > 0) {
// slide to the left (all the way)
while (node) {
stack.push(node);
node = node.left;
}