diff --git a/include/Tree/tree.hpp b/include/Tree/tree.hpp index a3f308a..ca16f78 100644 --- a/include/Tree/tree.hpp +++ b/include/Tree/tree.hpp @@ -52,6 +52,22 @@ namespace Tree std::list> children; public: + + /** + * @brief get the root of the tree + * + */ + std::shared_ptr getRoot() + { + if (parent==nullptr) + { + return shared_from_this(); + } + + return parent->getRoot(); + + } + /** * @brief print the tree starting with the current node to stdout *