def get_unique_child(parent, child_name, strict=True):
    """
    Get children node matching given name.

    Parameters
    ----------
    parent : xml element
        Parent node.
    child_name : str
        Name of the node to look for.
    strict : bool, optional
        Flag telling whether there should be strictly one
        child. If set to True, an error is raised if no child was found.

    Returns
    -------
    out : xml element or None
        Child if exactly one node is found. If no child is found,
        None is returned if strict was set to False.

    Raises
    ------
    UserWarning
        When no child is found and strict is set to True or
        when more than one node is found.

    """
    children = parent.findall(child_name)
    if len(children) == 1:
        return children[0]
    elif not children and not strict:
        return None
    else:
        if strict:
            raise UserWarning('A {} should have exactly one {} node child.'
                              .format(parent.tag, child_name))
        else:
            raise UserWarning('A {} should not have more than one {} node '
                              'children.'.format(parent.tag, child_name))