core: initial visiting algorithm