Function for traversing the filesystem to lookup paths

Still not quite happy with it, but it'll do for now