clean up `walk` utils method

use the `path` module to normalize file paths, refactor if statement.