Fix invariant issues.
Merge pull request #1413 from Microsoft/forEachChild

Fix invariant issues.