Added function to traverse a connected component starting from a slice

Contributed by @JonasKlein, @unidesigner