SOURCE

var X = {
    y: {
        c: {
            d: 1
        }
    },
    z: {
        e: {
            d: 2
        }
    },
    q: {
        f: {
            d: 3
        }
    },
    o: {
        m: {
            g: {
                h: {
                    d: 4
                }
            }
        }
    }
}

function deep(obj, k) {
    console.log(k);
    for (let i in obj) {
        if (i == k) {
            console.log(obj[i]);
        } else if (obj[i] instanceof Object) {
            deep(obj[i])
        } else {
            continue;
        }
    }
}

deep(X, 'd');
console 命令行工具 X clear

                    
>
console