- # FIXME - shouldn't have to delegate to the database to get this
- return $self->kdbx->all_groups(base => $self, include_base => false);
+
+ my @groups;
+ for my $subgroup (@{$self->groups}) {
+ push @groups, @{$subgroup->all_groups};
+ }
+
+ return \@groups;
+}
+
+=method find_groups
+
+ @groups = $kdbx->find_groups($query, %options);
+
+Find all groups deeply that match to a query. Options are the same as for L</all_groups>.
+
+See L</QUERY> for a description of what C<$query> can be.
+
+=cut
+
+sub find_groups {
+ my $self = shift;
+ my $query = shift or throw 'Must provide a query';
+ my %args = @_;
+ my %all_groups = ( # FIXME
+ base => $args{base},
+ include_base => $args{include_base},
+ );
+ return @{search($self->all_groups(%all_groups), is_arrayref($query) ? @$query : $query)};