def pad_list_with_last_elem(x, y, sym=False):
    """Pad list x with its last elem according of y list length, if sym
    is True, then pad also y.
    """
    if x is not None:
        if len(x) != len(y):
            diff = len(x) - len(y)
            if diff > 0 and sym:
                for i in range(diff):
                    y.append(y[-1])
            if diff < 0:
                for i in range(-diff):
                    x.append(x[-1])
    else:
        x = [None for i in range(len(y))]
    return x, y
