# Pastebin CGDZ7gJw use nqp; sub postcircumfix:<{; }>(\SELF, @indices, :$exists!) { multi recurse-at-key(\SELF, \indices, 0) { (False xx indices.map(*.elems).reduce(&infix:<*>)).List } multi recurse-at-key(\SELF, [@idx, +@indices]) { @idx.map( -> $idx { |recurse-at-key(SELF, ($idx, |@indices)) }).List } multi recurse-at-key(\SELF, [$idx, +@indices where *.elems > 0]) { nqp::if( nqp::not_i(SELF.EXISTS-KEY($idx)), recurse-at-key(SELF{$idx}, @indices, 0), recurse-at-key(SELF{$idx}, @indices), ) } multi recurse-at-key(\SELF, [$idx]) { SELF.EXISTS-KEY($idx) } recurse-at-key SELF, @indices } my %a = 1 => {2 => {3 => 42}}; dd %a{1;2;3}:exists; dd %a{-99;2;3}:exists; dd %a{-99;2,3;4}:exists; dd %a{1,1;2;3}:exists; dd %a{1;2,2;3}:exists; dd %a{1;2,2;3,3}:exists; dd %a{1,1;2,2;3,3}:exists; dd %a{1,1;-99,2;3,3}:exists;