in reply to recursive path function falls into infinite loop
Your check for . and .. is using the full path, so it will never match. There's your recursion.