diff --git a/include/blt/std/binary_tree.h b/include/blt/std/binary_tree.h index 1d08e67..a4fe660 100644 --- a/include/blt/std/binary_tree.h +++ b/include/blt/std/binary_tree.h @@ -71,12 +71,14 @@ namespace blt { return nullptr; // check for left and right tree traversal if it exists if (searchNode->left != nullptr && element < searchNode->left->payload) { - *parent = searchNode; + if (parent != nullptr) + *parent = searchNode; searchNode = searchNode->left; continue; } if (searchNode->right != nullptr && element > searchNode->right->payload) { - *parent = searchNode; + if (parent != nullptr) + *parent = searchNode; searchNode = searchNode->right; continue; }