def expr_to_tree(ind):
 def prim_to_list(prim, args):
  if isinstance(prim, deap.gp.Terminal):
   return prim.value
  return ([prim.name] + args)
 tree = []
 stack = []
 for node in ind:
  stack.append((node, []))
  while (len(stack[(-1)][1]) == stack[(-1)][0].arity):
   (prim, args) = stack.pop()
   tree = prim_to_list(prim, args)
   if (len(stack) == 0):
    break
   stack[(-1)][1].append(tree)
 return tree

def expr_to_tree ( ind ) : def prim_to_list ( prim , args ) : if isinstance ( prim , deap . gp . Terminal ) : return prim . value return ( [ prim . name ] + args ) tree = [ ] stack = [ ] for node in ind : stack . append ( ( node , [ ] ) ) while ( len ( stack [ ( - 1 ) ] [ 1 ] ) == stack [ ( - 1 ) ] [ 0 ] . arity ) : ( prim , args ) = stack . pop ( ) tree = prim_to_list ( prim , args ) if ( len ( stack ) == 0 ) : break stack [ ( - 1 ) ] [ 1 ] . append ( tree ) return tree
convert the unstructured deap pipeline into a tree data-structure parameters ind: deap .