SCH_SHEET* SCH_SHEET::GetRootSheet() { SCH_SHEET* sheet = dynamic_cast< SCH_SHEET* >( GetParent() ); if( sheet == NULL ) return this; // Recurse until a sheet is found with no parent which is the root sheet. return sheet->GetRootSheet(); }