“A person shall be entitled to a patent unless he did not himself invent the subject matter sought to be patented.”
This is pretty simple, the inventor on the application must be the true inventor of the application.
To overcome a 35 U.S.C. § 102(f) rejection one can use derivation. In order to use derivation successfully you must show proof that the entire invention was previously conceived by another. A small improvement from a previous invention can dissolve the derivation argument as it must be the entire invention.