def view_tree_set(v, treeset):
 treeset.add(v)
 for (cl, v_input_pos_to_cl) in v.clients:
  if (cl == 'output'):
   continue
  vmap = getattr(cl.op, 'view_map', {})
  dmap = getattr(cl.op, 'destroy_map', {})
  for (opos, iposlist) in chain(iteritems(vmap), iteritems(dmap)):
   if (v_input_pos_to_cl in iposlist):
    if (cl.outputs[opos] not in treeset):
     view_tree_set(cl.outputs[opos], treeset)

def view_tree_set ( v , treeset ) : treeset . add ( v ) for ( cl , v_input_pos_to_cl ) in v . clients : if ( cl == 'output' ) : continue vmap = getattr ( cl . op , 'view_map' , { } ) dmap = getattr ( cl . op , 'destroy_map' , { } ) for ( opos , iposlist ) in chain ( iteritems ( vmap ) , iteritems ( dmap ) ) : if ( v_input_pos_to_cl in iposlist ) : if ( cl . outputs [ opos ] not in treeset ) : view_tree_set ( cl . outputs [ opos ] , treeset )
add to treeset all variables that are views of v .