def ancestors(options = {})
      ids = []
      if options[:generations]
        raise ArgumentError, ":generations option must be an Integer" unless options[:generations].is_a? Integer
        generation_count = 0
        generation_ids = parents.compact.map(&:id)
        while (generation_count < options[:generations]) && (generation_ids.length > 0)
          next_gen_ids = []
          ids += generation_ids
          until generation_ids.empty?
            ids.unshift(generation_ids.shift)
            next_gen_ids += gclass.find(ids.first).parents.compact.map(&:id)
          end
          generation_ids = next_gen_ids
          generation_count += 1
        end
      else
        remaining_ids = parents.compact.map(&:id)
        until remaining_ids.empty?
          ids << remaining_ids.shift
          remaining_ids += gclass.find(ids.last).parents.compact.map(&:id)
        end
      end
      gclass.where(id: ids)
    end
def ancestors(options = {})
      ids = []
      if options[:generations]
        raise ArgumentError, ":generations option must be an Integer" unless options[:generations].is_a? Integer
        generation_count = 0
        generation_ids = parents.compact.map(&:id)
        while (generation_count < options[:generations]) && (generation_ids.length > 0)
          next_gen_ids = []
          ids += generation_ids
          until generation_ids.empty?
            ids.unshift(generation_ids.shift)
            next_gen_ids += gclass.find(ids.first).parents.compact.map(&:id)
          end
          generation_ids = next_gen_ids
          generation_count += 1
        end
      else
        remaining_ids = parents.compact.map(&:id)
        until remaining_ids.empty?
          ids << remaining_ids.shift
          remaining_ids += gclass.find(ids.last).parents.compact.map(&:id)
        end
      end
      gclass.where(id: ids)
    end
get list of known ancestrors iterateing over parents
 @param [Hash] options
 @option options [Symbol] generations lets you limit how many generations will be included in the output.
 @return [ActiveRecord::Relation] list of ancestors (limited by a number of generations if so indicated)