Get to 100% branch coverage

Exercise edge cases in branch statements.
@tseaver Can you add a comment above `if element.HasField('name'):` along the lines of
```python
            # This is safe: we expect objects returned from the proto will only have `name` or `id` set.
            if element.HasField('name'):
```