Get a nested property of an object or primitive