Not really an answer... more of a suggestion for an alternative implementation that eliminates recursion. Too long to post as a comment.
public IEnumerable<IPageNode> ancestorsOf(IPageNode pageNode) {
if(pageNode == null) throw new ArgumentNullException(("pageNode"));
Stack<IPageNode> stack = new Stack<IPageNode>();
stack.Push(pageNode);
while(stack.Any())
{
IPageNode n=stack.Pop();
if (n.url != pageNodeService.rootUrl) {
yield return n;
if(n.parent != null)
{
stack.Push(n.parent);
}
}
}
}
Thinking about it, you could remove the Stack altogether:
public IEnumerable<IPageNode> ancestorsOf(IPageNode pageNode) {
if(pageNode == null) throw new ArgumentNullException(("pageNode"));
IPageNode n = pageNode;
while(n != null && n.url != pageNodeService.rootUrl)
{
yield return n;
n = n.parent;
}
}