code: def prune_candidates(candidates):
      
      pruned = []
      # NOTE: In the below we replace ``isinstance(a, B)`` with
      #       ``a.__class__ is B``, which is a 3-3.5x speedup.
      for first, second in candidates:
          if first.__class__ is Linearization:
              nodes1 = first.curve.nodes
          else:
              nodes1 = first.nodes
          if second.__class__ is Linearization:
              nodes2 = second.curve.nodes
          else:
              nodes2 = second.nodes
          if convex_hull_collide(nodes1, nodes2):
              pruned.append((first, second))
      return pruned
docs: Reduce number of candidate intersection pairs.
  
      .. note::
  
         This is a helper for :func:`_all_intersections`.
  
      Uses more strict bounding box intersection predicate by forming the
      actual convex hull of each candidate curve segment and then checking
      if those convex hulls collide.
  
      Args:
          candidates (List): An iterable of pairs of curves (or
              linearized curves).
  
      Returns:
          List: A pruned list of curve pairs.