def extract_demonym(demonyms, gender):
    """
    Search through the list of demonyms and find the right one by gender
    :param demonyms:
    :param gender: may be male (u'Q499327') od female (u'Q1775415')
    :return: demonym in Serbian language
    """
    description = u''
    for demonym in demonyms:
        local_demonym = demonym.getTarget()
        if local_demonym.language == u'sr':
            demonym_qualifiers = demonym.qualifiers
            if 'P518' in demonym_qualifiers:
                demonym_gender = demonym_qualifiers['P518']
                if len(demonym_gender) > 1:
                    exit()
                demonym_gender = demonym_gender[0].target.id
                if demonym_gender == gender:
                    description += local_demonym.text
                    break
    return description