Revit critical path Logic

Anybody knows the logic used by revit to find critical path?..I want to write one dynamo script to find critical path for water supply pipes.

Not an M&E egineer so not sure how to answer your questions directly but a quick forum search returned these similar posts.

Have a look to see if any of them help explain the logic