PEP8
Handle actions better.

- Make sure they have a 'children' attribute.
- Make the template more robust for cases when items do not have children.