Searching an acts_as_tree model

If I have a Person model that acts_as_tree, how can I find a
particular person by drilling down through the family tree?

e.g.

for this family:

John
| |
Amy Dave
| |
Bob Bob

The urls

/john/amy/bob and /john/dave/bob

should find a different Person object. At the moment, I am doing it
like this:

  people = (params[:people])
  people.each do |person|
    if person == people.first
      @person = Page.find_by_name(people.first)
    else
      @person = @person.children.find_by_name(person
    end
  end

This hits the database quite a few times though. Is there a better way
to drill down to find the people?

DAZ

Look at nested sets. ActiveRecord::Acts::NestedSet::ClassMethods
With nested Sets it’s very simple to select the whole tree in one query.
Disadvantage of nested sets are the huge amount of operations if you
insert or update a tree node. But if you have small tree’s it’s the best
solution.

http://agilewebdevelopment.com/plugins/betternestedset