def get_import_statement(node, lines):
    """
    Gets the text of the full import statement associated with a node, which
    might be split across multiple lines.
    """
    offset = -1
    stmt = lines[node.lineno + offset].strip()

    # Join lines split by (
    while stmt.endswith("("):
        offset += 1
        stmt = stmt[:-1]
        stmt += lines[node.lineno + offset].strip()

    while stmt.endswith(")"):
        stmt = stmt[:-1]

    # Join lines split by \
    while stmt.endswith("\\"):
        offset += 1
        stmt = stmt[:-1]
        stmt += lines[node.lineno + offset].strip()

    return stmt