src/mongo/shell/explainable.js
// callback is executed last on the root.
callback is executed last on the root.
callback is executed last on the root .
function walkTree(root, callbackFn) {
            if ("inputStages" in root) {
                for (var i = 0; i < root.inputStages.length; i++) {
                    walkTree(root.inputStages[i], callbackFn);
                }
            }
            for (let childStageName
                     of ["inputStage", "thenStage", "elseStage", "outerStage", "innerStage"]) {
                if (childStageName in root) {
                    walkTree(root[childStageName], callbackFn);
                }
            }
            callbackFn(root);
        }
function walkTree ( root , callbackFn ) { if ( "inputStages" in root ) { for ( var i = 0 ; i < root . inputStages . length ; i ++ ) { walkTree ( root . inputStages [ i ] , callbackFn ) ; } } for ( let childStageName of [ "inputStage" , "thenStage" , "elseStage" , "outerStage" , "innerStage" ] ) { if ( childStageName in root ) { walkTree ( root [ childStageName ] , callbackFn ) ; } } callbackFn ( root ) ; }
callback is executed last on the root.
callback is executed last on the root .