Since SERVER-27550, the function sh.waitForBalancer() does not exist because it was deleted. The documentation for MongoDB 3.6 still lists it as existing: https://docs.mongodb.com/v3.6/reference/method/sh.waitForBalancer/#sh.waitForBalancer
The function is useful to users. Similar code exists in our testing frameworks to wait for migrations to finish.