def get_content_section(page):
    """
    Find the top-level parent in order to highlight
    the main nav item and set social images.
    Takes a Page object and returns a string of either 'legal', 'help', or ''
    """
    slugs = {
        'help-candidates-and-committees': 'help',
        'legal-resources': 'legal'
    }
    ancestors = page.get_ancestors()
    content_sections = [
        slugs.get(ancestor.slug) for ancestor in ancestors
        if slugs.get(ancestor.slug) != None
    ]
    if len(content_sections):
        return content_sections[0]
    else:
        return ''