Added `key` and `parentNode` arguments to callbacks for more control over traversal.