Bash Binary Search Tree Algorithm