Validate user-provided paths

When object or container methods are called with clearly invalid path
elements, raise a useful error message.  Previous behavior would've
resulted in potentially valid yet incorrect API calls. We don't want
this to be able to happen.

Thanks to @smashwilson for catching this one.