Fix max call stack error/bug

Optimization to skip calculating `firstChild` until it's needed.