docstr: Represents a complex nest of ImageCollections.
  
  On construction, the image collections are scanned for ancestry,
  leading to fast image finding capabilities.
  
  A complex (and time consuming to create) NestedImageCollection instance
  can be saved as a pickle file and subsequently be (quickly) restored.
  
  There is a simplified creation interface for NestedImageCollection
  ``from_configuration`` for more detail.
  
  Parameters
  ----------
  name
      The name of the nested image collection.
  crs
      The native :class:`~cartopy.crs.Projection` of all the image
      collections.
  collections
      A list of one or more :class:`~cartopy.io.img_nest.ImageCollection`
      instances.
docstr_tok: ["Represents","a","complex","nest","of","ImageCollections",".","On","construction",",","the","image","collections","are","scanned","for","ancestry",",","leading","to","fast","image","finding","capabilities",".","A","complex","(","and","time","consuming","to","create",")","NestedImageCollection","instance","can","be","saved","as","a","pickle","file","and","subsequently","be","(","quickly",")","restored",".","There","is","a","simplified","creation","interface","for","NestedImageCollection","``","from_configuration","``","for","more","detail",".","Parameters","--","--","--","--","--","name","The","name","of","the","nested","image","collection",".","crs","The","native",":","class",":","`","~cartopy.crs.Projection","`","of","all","the","image","collections",".","collections","A","list","of","one","or","more",":","class",":","`","~cartopy.io.img_nest.ImageCollection","`","instances","."]
code: def __init__(self, name, crs, collections, _ancestry=None):
      """
      Represents a complex nest of ImageCollections.
  
      On construction, the image collections are scanned for ancestry,
      leading to fast image finding capabilities.
  
      A complex (and time consuming to create) NestedImageCollection instance
      can be saved as a pickle file and subsequently be (quickly) restored.
  
      There is a simplified creation interface for NestedImageCollection
      ``from_configuration`` for more detail.
  
      Parameters
      ----------
      name
          The name of the nested image collection.
      crs
          The native :class:`~cartopy.crs.Projection` of all the image
          collections.
      collections
          A list of one or more :class:`~cartopy.io.img_nest.ImageCollection`
          instances.
  
      """
      # NOTE: all collections must have the same crs.
      _names = {collection.name for collection in collections}
      assert len(_names) == len(
          collections
      ), "The collections must have unique names."
  
      self.name = name
      self.crs = crs
      self._collections_by_name = {
          collection.name: collection for collection in collections
      }
  
      def sort_func(c):
          return np.max([image.bbox().area for image in c.images])
  
      self._collections = sorted(
          collections, key=sort_func, reverse=True
      )
      self._ancestry = {}
      """
          maps (collection name, image) to a list of children
          (collection name, image).
          """
      if _ancestry is not None:
          self._ancestry = _ancestry
      else:
          parent_wth_children = zip(
              self._collections, self._collections[1:]
          )
          for parent_collection, collection in parent_wth_children:
              for parent_image in parent_collection.images:
                  for image in collection.images:
                      if self._is_parent(parent_image, image):
                          # append the child image to the parent's ancestry
                          key = (parent_collection.name, parent_image)
                          self._ancestry.setdefault(key, []).append(
                              (collection.name, image)
                          )
  
imports: import collections
  from pathlib import Path
  import numpy
  from PIL import Image
  import shapely.geometry
label_desc: Use image node_id 1 to create a new NestedImageCollection object  with example: obj = NestedImageCollection(name, crs, collections, _ancestry)