def _get_datapoint(datapoints, name, tags=None):
    """Find a specific datapoint by name and tags

    :param datapoints: a list of datapoints
    :type datapoints: [dict]
    :param name: the name of the required datapoint
    :type name: str
    :param tags: required tags by key and value
    :type tags: dict
    :return: a matching datapoint
    :rtype: dict
    """
    for datapoint in datapoints:
        if datapoint['name'] == name:
            if tags is None:
                return datapoint

            dtags = datapoint.get('tags', {})
            tag_match = True
            for k, v in tags.items():
                tag_match = tag_match and dtags.get(k) == v
            if tag_match:
                return datapoint