@sipa: ACK.  Replacing the recursion with:

```
-            if (parent == NULL || !parent->IsTrusted())
+            if (parent == NULL || !parent->IsFromMe() || parent->GetDepthInMainChain() < 0)
```