Staking node can be inappropriately removed from the tree
The following code in `OrchidDirectory.pull()` is responsible for reattaching a child from a removed tree node:\\n```\\nif (name(stake.left\\_) == key) {\\n    current.right\\_ = stake.right\\_;\\n    current.after\\_ = stake.after\\_;\\n} else {\\n    current.left\\_ = stake.left\\_;\\n    current.before\\_ = stake.before\\_;\\n}\\n```\\n\\nThe condition name(stake.left_) == `key` can never hold because `key` is the `key` for `stake` itself.\\nThe result of this bug is somewhat catastrophic. The child is not reattached, but it still has a link to the rest of the tree via its ‘parent_' pointer. This means reducing the stake of that node can underflow the ancestors' before/after amounts, leading to improper random selection or failing altogether.\\nThe node replacing the removed node also ends up with itself as a child, which violates the basic tree structure and is again likely to produce integer underflows and other failures.
As a simple fix, use `if(name(stake.left_) == name(last))` as already suggested by the development team when this bug was first shared.\\nTwo suggestions for better long-term fixes:\\nUse a strict interface for tree operations. It should be impossible to update a node's parent without simultaneously updating that parent's child pointer.\\nAs suggested in (https://github.com/ConsenSys/orchid-audit-2019-10/issues/7), simplify the logic in `pull()` to avoid this logic altogether.
```\\nif (name(stake.left\\_) == key) {\\n    current.right\\_ = stake.right\\_;\\n    current.after\\_ = stake.after\\_;\\n} else {\\n    current.left\\_ = stake.left\\_;\\n    current.before\\_ = stake.before\\_;\\n}\\n```\\n