Close. It's better to do something like:
```
if 'metadata' in node.extra and 'profile' in node.extra['metadata']:
```