# Pastebin aPL55Xzq multi sub postcircumfix:<{; }>(\SELF, @indices, :$exists!) { multi recurse-at-key(\SELF, @indices) { return @indices[0].map({ |recurse-at-key(SELF, ($_, |@indices[1 .. @indices.end])) }).List if @indices[0] ~~ List; return SELF.EXISTS-KEY(@indices[0]) if @indices == 1; do if SELF.EXISTS-KEY(@indices[0]) { recurse-at-key SELF{@indices[0]}, @indices[1 .. @indices.end] } else { my $num = @indices.map({ .elems }).reduce(&[*]); return False if $num == 1; (False xx $num).List } } recurse-at-key(SELF, @indices) } use Test; my %a = 1 => {2 => {3 => 42}}; is-deeply %a{1;2;3}:exists, True; is-deeply %a{-99;2;3}:exists, False; is-deeply %a{1;-99;3}:exists, False; is-deeply %a{1;2;-99}:exists, False; is-deeply %a{1,1;2;3}:exists, (True, True); is-deeply %a{1;2,2;3}:exists, (True, True); is-deeply %a{1;2;3,3}:exists, (True, True); is-deeply %a{1,-99;2;3}:exists, (True, False); is-deeply %a{1;2,-99;3}:exists, (True, False); is-deeply %a{1;2;3,-99}:exists, (True, False); is-deeply %a{1,1;2,2;3}:exists, (True, True, True, True); is-deeply %a{1,1;2;3,3}:exists, (True, True, True, True); is-deeply %a{1;2,2;3,3}:exists, (True, True, True, True); is-deeply %a{1,1;2,2;3,3}:exists, (True, True, True, True, True, True, True, True);