code: def path_to_attr(path):
      
      return reduce(lambda hpath, last: ast.Attribute(hpath, last, ast.Load()),
                    path[1:], ast.Name(mangle(path[0]), ast.Load(), None))
docs: Transform path to ast.Attribute.
  
      >>> import gast as ast
      >>> path = ('__builtin__', 'my', 'constant')
      >>> value = path_to_attr(path)
      >>> ref = ast.Attribute(
      ...     value=ast.Attribute(value=ast.Name(id="__builtin__",
      ...                                        ctx=ast.Load(),
      ...                                        annotation=None),
      ...                         attr="my", ctx=ast.Load()),
      ...     attr="constant", ctx=ast.Load())
      >>> ast.dump(ref) == ast.dump(value)
      True