def SpliceContinuations(tree):

  def RecSplicer(node):
    if isinstance(node, pytree.Leaf):
      if node.prefix.lstrip().startswith('\\\n'):
        new_lineno = node.lineno - node.prefix.count('\n')
        return pytree.Leaf(type=format_token.CONTINUATION,
                           value=node.prefix,
                           context=('', (new_lineno, 0)))
      return None
    num_inserted = 0
    for index, child in enumerate(node.children[:]):
      continuation_node = RecSplicer(child)
      if continuation_node:
        node.children.insert(index + num_inserted, continuation_node)
        num_inserted += 1

  RecSplicer(tree)
Given a pytree, splice the continuation marker into nodes.
dataset/ETHPy150Open google/yapf/yapf/yapflib/continuation_splicer.py/SpliceContinuations