code: def to_gremlin(self):
          
          self.validate()
          template = 'copySplit({recurse}).exhaustMerge'
          recurse_base = '_()'
          recurse_traversal = '.{direction}(\'{edge_name}\')'.format(
              direction=self.direction, edge_name=self.edge_name)
  
          recurse_steps = [
              recurse_base + (recurse_traversal * i)
              for i in six.moves.xrange(self.depth + 1)
          ]
          recursion_string = template.format(recurse=','.join(recurse_steps))
          if self.within_optional_scope:
              # During a traversal, the pipeline element may be null.
              # The following code returns null when the current pipeline entity is null
              # (an optional edge did not exist at some earlier traverse).
              # Otherwise it performs a normal recursion (previous optional edge did exist).
              recurse_template = u'ifThenElse{{it == null}}{{null}}{{it.{recursion_string}}}'
              return recurse_template.format(recursion_string=recursion_string)
          else:
              return recursion_string
docs: Return a unicode object with the Gremlin representation of this block.