diff --git a/include/blt/std/binary_tree.h b/include/blt/std/binary_tree.h index a070f81..1d08e67 100644 --- a/include/blt/std/binary_tree.h +++ b/include/blt/std/binary_tree.h @@ -67,6 +67,8 @@ namespace blt { while (true) { if (searchNode->payload == element) return searchNode; + if (searchNode->left == nullptr && searchNode->right == nullptr) + return nullptr; // check for left and right tree traversal if it exists if (searchNode->left != nullptr && element < searchNode->left->payload) { *parent = searchNode;