def shift_positions(cur, node, position, offset):
    """
    Shift all children of ``node`` at ``position`` by ``offset``.

    :param node:
    :type node: Node or int
    :param int position:
    :param int offset: Positive value for right shift, negative value
                       for left shift
    """
    if node is not None:
        id = int(node)
    else:
        id = None

    sql = """
        UPDATE
          nodes
        SET
          position=position{}
        WHERE
          parent=%s
        AND
          position >= %s;
    """
    delta = ''
    if offset > 0:
        delta = '+{}'.format(offset)
    elif 0 < offset:
        delta = '{}'.format(offset)

    sql = sql.format(delta)
    cur.execute(sql, (id, position))
dataset/ETHPy150Open conceptsandtraining/libtree/libtree/core/positioning.py/shift_positions/swapped operands of `<`