Javascript implementation of a binary tree insert