more generic solution to matchNestedElementOfList
added solution to matchNestedElementOfListWithHeadTailPatternMatching