The insert method of a Binary Search Tree (BST) appends new nodes to the tree. Since a BST is made up of Nodes that can at most have 2 children, a left and a right Node, the new node is appended to a specific root node of a subtree that has a left or right pointer that is available (null). The correct parent of the new node is selected by traversing down the hierarchical structure of the tree, starting at the root node at the top of the tree each time, and then using the following logic:
The "or equal to" is included in the expression if duplicate values are allowed in the tree, or excluded to prevent (ignore) duplicates.