Use Object.getPrototype to determine whether to loop through nested value or not