def remove_alignments(tree, search_string):
    """
    Removes all linkGrp-tags that do not contain the provided search string.
    :param tree: the current XML tree
    :param search_string: the search string
    :return: The tree with linkGrp-tags removed that do not contain the search string
    """
    for linkGrp in tree.xpath('//linkGrp[not(contains(@fromDoc, "{}"))]'.format(search_string)):
        linkGrp.getparent().remove(linkGrp)
    return tree