Finding a Physique Modifier

Below is a code example, for finding a physique modifier if it exists for a given INode:

Modifier* FindPhysiqueModifier (INode* nodePtr)
{
  // Get object from node. Abort if no object.
  Object* ObjectPtr = nodePtr->GetObjectRef();
 
  if (!ObjectPtr) return NULL;
  // Is derived object ?
  while (ObjectPtr && ObjectPtr->SuperClassID() == GEN_DERIVOB_CLASS_ID)
  {
    // Yes -> Cast.
     IDerivedObject *DerivedObjectPtr = ( IDerivedObject *)(ObjectPtr);
 
    // Iterate over all entries of the modifier stack.
    int ModStackIndex = 0;
    while (ModStackIndex < DerivedObjectPtr->NumModifiers())
    {
      // Get current modifier.
      Modifier* ModifierPtr = DerivedObjectPtr->GetModifier(ModStackIndex);
 
      // Is this Physique ?
      if (ModifierPtr->ClassID() == Class_ID(PHYSIQUE_CLASS_ID_A, PHYSIQUE_CLASS_ID_B)) {
        // Yes -> Exit.
        return ModifierPtr;
      }
 
      // Next modifier stack entry.
      ModStackIndex++;
    }
    ObjectPtr = DerivedObjectPtr->GetObjRef();
  }
 
  // Not found.
  return NULL;
}