Add check for internal data in attach internal node function.

Since internal data is a pointer and isn't guaranteed we should check that it
exists before dereferencing it.