populates the ancestor stack