Another go on algorithm for finding unique directory path