code: def _process_tree(self, thisTree, thatTree):
          if self.debug:
              sys.stdout.write("Processing Tree: ")
              start = time.clock()
          if len(thisTree.nodes()) > 1:
              leaves = set(
                  [
                      v
                      for v in thisTree.nodes()
                      if thisTree.in_degree(v) == 0 and thatTree.in_degree(v) < 2
                  ]
              )
          else:
              leaves = set()
          while len(leaves) > 0:
              v = leaves.pop()
              edges = list(thisTree.out_edges(v))
              if len(edges) != 1:
                  warnings.warn(
                      "The node {} should have a single emanating "
                      "edge.\n".format(v)
                  )
              e1 = edges[0][0]
              e2 = edges[0][1]
              if self.Y[e1] < self.Y[e2]:
                  self.edges.append((e1, e2))
              else:
                  self.edges.append((e2, e1))
              thisTree.remove_node(v)
              if thatTree.out_degree(v) == 0:
                  thatTree.remove_node(v)
              else:
                  if len(thatTree.in_edges(v)) > 0:
                      startNode = list(thatTree.in_edges(v))[0][0]
                  else:
                      startNode = None
                  if len(thatTree.out_edges(v)) > 0:
                      endNode = list(thatTree.out_edges(v))[0][1]
                  else:
                      endNode = None
                  if startNode is not None and endNode is not None:
                      thatTree.add_edge(startNode, endNode)
                  thatTree.remove_node(v)
              if len(thisTree.nodes()) > 1:
                  leaves = set(
                      [
                          v
                          for v in thisTree.nodes()
                          if thisTree.in_degree(v) == 0
                          and thatTree.in_degree(v) < 2
                      ]
                  )
              else:
                  leaves = set()
          if self.debug:
              end = time.clock()
              sys.stdout.write("%f s\n" % (end - start))