sub fooqux { $aref = shift; splice @$aref, 0, @$aref, map { fooqux( $_-> { value }) if $_-> { type } eq 'items'; SPLIT_IF_FOO( $_ ) } @$aref }