Slice potatoes using a mandolin (1/8-1/4" thick), and soak in water for 15-30 minutes to remove a lot of the starch (drain and refill with water once). After soaking (takes the 'gumminess' out of them), drain well.
Slice bacon into 1/4" pieces and cook until crisp. Slice onions using a mandolin (1/8-1/4" thick) and fry with 2 Tbsp oil until caramelized (turns golden).
Grease a 10 inch pie plate or casserole dish. Spread a layer of potatoes, then onions, bacon and some leaves of the parsley, then season with salt and pepper. Repeat layers 2 more times or until all ingredients are used up (make sure the last layer is a potato).
Whisk together the egg and milk and pour mixture over potatoes. Cover and bake at 375°F for 45 minutes (remove cover for last 10 minutes of baking). Remove, add grated cheese and broil until cheese is melted.