def add_to_existing_container(storable)
      if storage_type.nil? then
        raise Jinx::ValidationError.new("Cannot add #{storable.qp} to #{qp} with missing storage type")
      end
      # the subcontainers in column, row sort order
      scs = subcontainers.sort { |sc1, sc2| sc1.position.coordinate <=> sc2.position.coordinate }
      logger.debug { "Looking for a #{self} subcontainer from among #{scs.pp_s} to place #{storable.qp}..." } unless scs.empty?
      # The first subcontainer that can hold the storable is preferred.
      sc = scs.detect do |sc|
        # Check for circular reference. This occurred as a result of the caTissue bug described
        # in CaTissue::Database#query_object. The work-around circumvents the bug for now, but
        # it doesn't hurt to check again.
        if identifier and sc.identifier == identifier then
          raise Jinx::ValidationError.new("#{self} has a circular containment reference to subcontainer #{sc}")
        end
        # No circular reference; add to subcontainer if possible.
        sc.add_to_existing_container(storable) if StorageContainer === sc
      end
      if sc then
        logger.debug { "#{self} subcontainer #{sc} stored #{storable.qp}." }
        self
      elsif can_hold_child?(storable) then
        logger.debug { "#{self} can hold #{storable.qp}." }
        add_local(storable)
      else
        logger.debug { "Neither #{self} of type #{storage_type.name} nor its subcontainers can hold #{storable.qp}." }
        nil
      end
    end
def add_to_existing_container(storable)
      if storage_type.nil? then
        raise Jinx::ValidationError.new("Cannot add #{storable.qp} to #{qp} with missing storage type")
      end
      # the subcontainers in column, row sort order
      scs = subcontainers.sort { |sc1, sc2| sc1.position.coordinate <=> sc2.position.coordinate }
      logger.debug { "Looking for a #{self} subcontainer from among #{scs.pp_s} to place #{storable.qp}..." } unless scs.empty?
      # The first subcontainer that can hold the storable is preferred.
      sc = scs.detect do |sc|
        # Check for circular reference. This occurred as a result of the caTissue bug described
        # in CaTissue::Database#query_object. The work-around circumvents the bug for now, but
        # it doesn't hurt to check again.
        if identifier and sc.identifier == identifier then
          raise Jinx::ValidationError.new("#{self} has a circular containment reference to subcontainer #{sc}")
        end
        # No circular reference; add to subcontainer if possible.
        sc.add_to_existing_container(storable) if StorageContainer === sc
      end
      if sc then
        logger.debug { "#{self} subcontainer #{sc} stored #{storable.qp}." }
        self
      elsif can_hold_child?(storable) then
        logger.debug { "#{self} can hold #{storable.qp}." }
        add_local(storable)
      else
        logger.debug { "Neither #{self} of type #{storage_type.name} nor its subcontainers can hold #{storable.qp}." }
        nil
      end
    end
Adds the given storable to a container within this StorageContainer's hierarchy.

 @param @storable (see #add)
 @return [StorageContainer, nil] self if added, nil otherwise
 @raise [Jinx::ValidationError] if this container does not have a storage type, or if a circular
   containment reference is detected