Fix validation in get neighbors method.