How to optimize the recursive query?
There is a shorter exposition on this topic at http://www.ibase.ru/devinfo/DBMSTrees/sqltrees.html. But I worry that link is not endorsed by the author.
In any event, you need to refactor your code to use a more effective self-join and avoid both the CTE and the MAXRECURSION option.
Hope that helps,