One shall be careful when modifying an array which is being iterated. Even though the iteration always finishes in this particular case, it may generate many duplicate nodes in the result. The fix prevents this.
Fix the descendants method
Yep, this definitely looks like a bug. I'll merge and test this later today. Thanks for the patch!