code: def _visit(self, L, marked, tempmarked):
          
          assert not self.is_pseudo
          if self in tempmarked:
              raise Exception('feature graph is cyclic')
          if self not in marked:
              tempmarked[self] = True
              features = list()
              if self.siblings is not None and self.is_toplevel:
                  features.extend(reversed(self.siblings))
              if self.children is not None:
                  features.extend(reversed(self.children))
              if len(features) > 0:
                  for feature in features:
                      feature._visit(L, marked, tempmarked)
              marked[self] = True
              del tempmarked[self]
              L.insert(0, self)
docs: Sort features topologically.
  
          This recursive function uses depth-first search to find an ordering of
          the features in the feature graph that is sorted both topologically and
          with respect to genome coordinates.
  
          Implementation based on Wikipedia's description of the algorithm in
          Cormen's *Introduction to Algorithms*.
          http://en.wikipedia.org/wiki/Topological_sorting#Algorithms
  
          There are potentially many valid topological sorts of a feature graph,
          but only one that is also sorted with respect to genome coordinates
          (excluding different orderings of, for example, exons and CDS features
          with the same coordinates). Iterating through feature children in
          reversed order (in this functions' inner-most loop) seems to be the key
          to sorting with respect to genome coordinates.