first implementation, no tests
check processed nodes when getting nearest index