Safely set and get values on an object, regardless of depth