When implementing TransClusion there should be some kind of loaded wikis list, to prevent them from loading again.
This would also prevent a wiki from transcluding itself.
The solution to the recursion problem is the same as any graph traversal where you might have a cycle. Just maintain a stack of visited nodes. When encountering a new node, scan the stack for that new node. If it exists in the stack, then it's already been visited in this arc, so don't process that new node.