Also fwd declare types nested in namespaces.
Analyze and fwd declare all dependencies (ROOT-6705 ROOT-6719 ROOT-6712 ROOT-6695).
Fix mem corruption: iterator might be invalidated by insertion.