Fixed graph validation.

In some specific cases, there were shown unnecessary "unreachable code"
and "not every code path returns a value" warnings.