refactor: check childContainsOptionalChain to bail out before panic