Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Findings:
buildTree
When given a set of points with same coordinates in a dimension, they end up in left and right part of the tree. Is this within spec? Not sure. However the nodeSearch function expects exactly this and will fail and returns nothing, thus nothing is removed.
My fix is a search for differences in the coordinates and split there. This can lead to unbalanced trees, optimizing is left to the user :)
removeNode
This function resorts the tree when a root node is removed, results where strange, I skipped it and instead I rebuild the subtree using the buildTree func.
Sideeffects
Sorry my editor did reformat some of the code.
Did not rebuild min.js