This is great because the std::vector<T> class does not contain specific instances of type T in it: it is usually implemented using pointers. Creating an instance of the std::vector<TreeNode> does not require a full TreeNode definition.
std::vector<T> usually implemented as a triple of pointers (although this is not required by the standard):
template <typename T> class vector { ... T* start; T* end; T* end_of_storage; };
If std::vector<T> contains specific instances of T in it, then you will have a problem. The following is not legal C ++, because it creates a circular "has" definition:
template <typename T> class container { T x; }; class TreeNode { container<TreeNode> subNodes; };
source share