That sounds like one heck of a family tree. You may want to rethink your design before you try to get hard into any implementation. If there is any better way to do it, I would recommend going in that direction.