def _compute_lcs_elements(trace, x, y):
    """
    Compute the elements of a LCS given a pre-computed trace table.
    In this table, the key is (i, j) coordinate drawn from x and y, and the value is:

    - 'd': goes diagonal.
    - 'u': goes up.
    - 'l': goes left.

    :param trace: dict. A trace table.
    :param x:
    :param y:
    :return:
    """
    i, j = len(x), len(y)
    elements = set()
    while i != 0 and j != 0:
        if trace[i, j] == 'd':
            i -= 1
            j -= 1
            elements.add((i, j))
        elif trace[i, j] == 'u':
            i -= 1
        else:
            j -= 1
    return elements