static bool _isChildOfNode( QgsLayerTreeNode* child, QgsLayerTreeNode* node ) { if ( !child->parent() ) return false; if ( child->parent() == node ) return true; return _isChildOfNode( child->parent(), node ); }
foreach ( QgsLayerTreeNode* n, nodes ) { if ( _isChildOfNode( child, n ) ) return true; }
Q_FOREACH ( QgsLayerTreeNode* n, nodes ) { if ( _isChildOfNode( child, n ) ) return true; }