Fix potencial out of bounds exception

Check if the child index is available before looking for it, avoiding a potencial out of bounds exception