def find_near_node(s, node, offsetresolver, offset=None):
    """
    Find the begin and end position of string S if it exists on the same line as NODE
    """
    line = offsetresolver.lines[node.lineno-1]
    if not offset:
        offset = offsetresolver.nodeoffset(node)
    begin = offsetresolver.src.index(s, offset)
    if begin - offset > len(line):
        raise ValueError("could not find '%s' on line '%s'", line)
    end = begin + len(s)
    return begin, end