When selecting a successor, you always begin with the end in mind. It's important to look within your organization to see if there's a talent or a person that you could groom to be your replacement. You often don't have the benefit of knowing though. If you're planning your retirement and there are things within your control, then you can do that.
But if there's an unexpected reason for you leaving the company, then that would pose a problem. Therefore, it's important to look in your ranks to see talent, maybe one or two persons. Then take them under your wing and mentor them, so that they will be in a position to be your successor.