function deal(source) {
let result = source.val;
function find(node) {
if (node.val > result) {
result = node.val;
}
Object.keys(node).forEach(key => {
if (typeof node[key] === 'object') {
find(node[key]);
}
});
}
find(source);
return result;
}
const data = {val: 1, b: {val: 2, b: {val: 1}, c: {val: 4}}};
console.log(deal(data));