File: opal_tree.c

package info (click to toggle)
openmpi 4.1.0-10
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 126,560 kB
  • sloc: ansic: 685,465; makefile: 42,952; f90: 19,220; sh: 7,002; java: 6,360; perl: 3,524; cpp: 2,227; python: 1,350; lex: 989; fortran: 61; tcl: 12
file content (707 lines) | stat: -rw-r--r-- 22,082 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
/*
 * Copyright (c) 2011      Oracle and/or its affiliates.  All rights reserved.
 * Copyright (c) 2011      Oak Ridge National Labs.  All rights reserved.
 * Copyright (c) 2012      The University of Tennessee and The University
 *                         of Tennessee Research Foundation.  All rights
 *                         reserved.
 * Copyright (c) 2013      Cisco Systems, Inc.  All rights reserved.
 * Copyright (c) 2014      Research Organization for Information Science
 *                         and Technology (RIST). All rights reserved.
 * $COPYRIGHT$
 *
 * Additional copyrights may follow
 *
 * $HEADER$
 */

#include "opal_config.h"

#include "opal/class/opal_tree.h"
#include "opal/constants.h"

/*
 *  List classes
 */

static void opal_tree_item_construct(opal_tree_item_t*);
static void opal_tree_item_destruct(opal_tree_item_t*);

OBJ_CLASS_INSTANCE(
                   opal_tree_item_t,
                   opal_object_t,
                   opal_tree_item_construct,
                   opal_tree_item_destruct
                   );

static void opal_tree_construct(opal_tree_t*);
static void opal_tree_destruct(opal_tree_t*);

OBJ_CLASS_INSTANCE(
                   opal_tree_t,
                   opal_object_t,
                   opal_tree_construct,
                   opal_tree_destruct
                   );


/*
 *
 *      opal_tree_item_t interface
 *
 */

static void opal_tree_item_construct(opal_tree_item_t *item)
{
    item->opal_tree_parent = NULL;
    item->opal_tree_num_ancestors = 0;
    item->opal_tree_sibling_rank = 0xdeadbeef;
    item->opal_tree_next_sibling = item->opal_tree_prev_sibling = NULL;
    item->opal_tree_num_children = 0;
    item->opal_tree_first_child = item->opal_tree_last_child = NULL;
#if OPAL_ENABLE_DEBUG
    item->opal_tree_item_refcount = 0;
    item->opal_tree_item_belong_to = NULL;
#endif
}

static void opal_tree_item_destruct(opal_tree_item_t *item)
{
#if OPAL_ENABLE_DEBUG
    assert( 0 == item->opal_tree_item_refcount );
    assert( NULL == item->opal_tree_item_belong_to );
#endif  /* OPAL_ENABLE_DEBUG */
}


/*
 *
 *      opal_tree_t interface
 *
 */

static void opal_tree_construct(opal_tree_t *tree)
{
    OBJ_CONSTRUCT( &(tree->opal_tree_sentinel), opal_tree_item_t );

#if OPAL_ENABLE_DEBUG
    /* These refcounts should never be used in assertions because they
       should never be removed from this list, added to another list,
       etc.  So set them to sentinel values. */

    tree->opal_tree_sentinel.opal_tree_item_refcount  = 1;
    tree->opal_tree_sentinel.opal_tree_item_belong_to = tree;
#endif
    tree->opal_tree_sentinel.opal_tree_container = tree;
    tree->opal_tree_sentinel.opal_tree_parent = &tree->opal_tree_sentinel;
    tree->opal_tree_sentinel.opal_tree_num_ancestors = -1;

    tree->opal_tree_sentinel.opal_tree_next_sibling =
        &tree->opal_tree_sentinel;
    tree->opal_tree_sentinel.opal_tree_prev_sibling =
        &tree->opal_tree_sentinel;

    tree->opal_tree_sentinel.opal_tree_first_child = &tree->opal_tree_sentinel;
    tree->opal_tree_sentinel.opal_tree_last_child = &tree->opal_tree_sentinel;

    tree->opal_tree_num_items = 0;
    tree->comp = NULL;
    tree->serialize = NULL;
    tree->deserialize = NULL;
    tree->get_key = NULL;
}

/*
 * Reset all the pointers to be NULL -- do not actually destroy
 * anything.
 */
static void opal_tree_destruct(opal_tree_t *tree)
{
    opal_tree_construct(tree);
}

/*
 * initialize tree container
 */
void opal_tree_init(opal_tree_t *tree, opal_tree_comp_fn_t comp,
                    opal_tree_item_serialize_fn_t serialize,
                    opal_tree_item_deserialize_fn_t deserialize,
                    opal_tree_get_key_fn_t get_key)
{
    tree->comp = comp;
    tree->serialize = serialize;
    tree->deserialize = deserialize;
    tree->get_key = get_key;
}

/*
 * count all the descendants from our level and below
 */
static int count_descendants(opal_tree_item_t* item)
{
    int current_count = 0;

    /* loop over all siblings for descendants to count */
    while (item) {
        current_count += count_descendants(opal_tree_get_first_child(item));
        current_count++; /* count ourselves */
        item = opal_tree_get_next_sibling(item);
    }
    return(current_count);
}

/*
 * get size of tree
 */
size_t opal_tree_get_size(opal_tree_t* tree)
{
#if OPAL_ENABLE_DEBUG
    /* not sure if we really want this running in devel, as it does
     * slow things down.  Wanted for development of splice / join to
     * make sure length was reset properly
     */
    size_t check_len = 0;
    opal_tree_item_t *root;

    if (!opal_tree_is_empty(tree)) {
        /* tree has entries so count up items */
        root = opal_tree_get_root(tree);
        check_len = count_descendants(root);
    }

    if (check_len != tree->opal_tree_num_items) {
        fprintf(stderr," Error :: opal_tree_get_size - opal_tree_num_items does not match actual tree length\n");
        fflush(stderr);
        abort();
    }
#endif

    return tree->opal_tree_num_items;
}

/*
 * add item to parent's child list
 */
void opal_tree_add_child(opal_tree_item_t *parent_item,
                         opal_tree_item_t *new_item)
{
#if OPAL_ENABLE_DEBUG
    /* Spot check: ensure that this item is previously on no lists */

    assert(0 == new_item->opal_tree_item_refcount);
    assert( NULL == new_item->opal_tree_item_belong_to );
#endif

    new_item->opal_tree_parent = parent_item;
    new_item->opal_tree_num_ancestors = parent_item->opal_tree_num_ancestors+1;
    if (parent_item->opal_tree_num_children) {
        /* append item to end of children and sibling lists */
        new_item->opal_tree_prev_sibling = parent_item->opal_tree_last_child;
        parent_item->opal_tree_last_child->opal_tree_next_sibling = new_item;
    } else {
        /* no children existing on parent */
        parent_item->opal_tree_first_child = new_item;
    }
    parent_item->opal_tree_last_child = new_item;
    parent_item->opal_tree_num_children++;
    new_item->opal_tree_container = parent_item->opal_tree_container;
    new_item->opal_tree_container->opal_tree_num_items++;

#if OPAL_ENABLE_DEBUG
    /* Spot check: ensure this item is only on the list that we just
       appended it to */

    OPAL_THREAD_ADD_FETCH32( &(new_item->opal_tree_item_refcount), 1 );
    assert(1 == new_item->opal_tree_item_refcount);
    new_item->opal_tree_item_belong_to = new_item->opal_tree_container;
#endif
}

/*
 * check to see if item is in tree
 */
#if OPAL_ENABLE_DEBUG
static bool item_in_tree(opal_tree_item_t *item, opal_tree_item_t *search_item)
{
    bool result = false;
    opal_tree_item_t *first_child;

    while (!result && item) {
        /* check for item match */
        result = (item == search_item) ? true : false;
        if (!result && (first_child = opal_tree_get_first_child(item))) {
            /* search descendants for match */
            result = item_in_tree(first_child, search_item);
        }
        if (!result) {
            /* didn't find match at our node or descending so check sibling */
            item = opal_tree_get_next_sibling(item);
        }
    }
    return(result);
}
#endif  /* OPAL_ENABLE_DEBUG */

/*
 * remove item and all items below it from tree and return it to the caller
 */
opal_tree_item_t *opal_tree_remove_subtree(opal_tree_item_t *item)
{
    opal_tree_item_t *parent_item = NULL;

#if OPAL_ENABLE_DEBUG
    /* validate that item does exist on tree */
    if (NULL != item->opal_tree_container) {
        /* we point to a container, check if we can find item in tree */
        if (!item_in_tree(opal_tree_get_root(item->opal_tree_container), item)) {
            return(NULL);
        }
    } else {
        return (NULL);
    }
#endif

    parent_item = item->opal_tree_parent;

    /* remove from parent */
    /* If item is the only child, set _first_child and _last_child to
       be item's _first_child and _last_child */
    if (parent_item->opal_tree_first_child == item &&
        parent_item->opal_tree_last_child == item) {
        parent_item->opal_tree_first_child = item->opal_tree_first_child;
        parent_item->opal_tree_last_child = item->opal_tree_last_child;
    } else {
        /* Otherwise, there are multiple children of this parent.  If
           this item is the first or last child of this parent, then
           ensure that the parent gets a valid first / last child:
           - If I have children, then my first/last child
           - If I have no children, then my immediate sibling */
        if (item->opal_tree_parent->opal_tree_first_child == item) {
            if (item->opal_tree_num_children > 0) {
                parent_item->opal_tree_first_child =
                    item->opal_tree_next_sibling;
            } else {
                parent_item->opal_tree_first_child =
                    opal_tree_get_next_sibling(item);
            }
        } else if (parent_item->opal_tree_last_child == item) {
            if (item->opal_tree_num_children > 0) {
                parent_item->opal_tree_last_child =
                    item->opal_tree_last_child;
            } else {
                parent_item->opal_tree_last_child =
                    opal_tree_get_prev_sibling(item);
            }
        }
    }
    item->opal_tree_parent->opal_tree_num_children--;

    /* remove from sibling pointers */
    if (NULL != item->opal_tree_prev_sibling) {
        item->opal_tree_prev_sibling->opal_tree_next_sibling=
            item->opal_tree_next_sibling;
    }
    if (NULL != item->opal_tree_next_sibling) {
        item->opal_tree_next_sibling->opal_tree_prev_sibling=
            item->opal_tree_prev_sibling;
    }
    item->opal_tree_prev_sibling = NULL;
    item->opal_tree_next_sibling = NULL;

    /* adjust items relating to container */
    item->opal_tree_container->opal_tree_num_items -= count_descendants(item);
    item->opal_tree_container = NULL;

    return(item);
}

int opal_tree_remove_item(opal_tree_t *tree,
                          opal_tree_item_t *item)
{
    opal_tree_item_t *parent_item = NULL, *child = NULL;

    parent_item = (opal_tree_item_t*)item->opal_tree_parent;

    /*
     * Point each of my children to my parent
     */
    for(child  = opal_tree_get_first_child(item);
        child != NULL;
        child  = opal_tree_get_next_sibling(child)) {
        child->opal_tree_parent = parent_item;
        child->opal_tree_num_ancestors--;

        parent_item->opal_tree_num_children++;
    }

    /*
     * My first child points to my 'prev' sibling
     */
    child  = opal_tree_get_first_child(item);
    if( NULL != child ) {
        child->opal_tree_prev_sibling = item->opal_tree_prev_sibling;
    }
    if( NULL != item->opal_tree_prev_sibling ) {
        (item->opal_tree_prev_sibling)->opal_tree_next_sibling = child;
    }

    child  = opal_tree_get_last_child(item);
    if( NULL != child ) {
        child->opal_tree_next_sibling = item->opal_tree_next_sibling;
    }
    if( NULL != item->opal_tree_next_sibling ) {
        (item->opal_tree_next_sibling)->opal_tree_prev_sibling = child;
    }

    /*
     * Remove me from my parent.  If I was the only child, then make
     * the first child be my first child, and make the last child be
     * my last child.
     */
    if( parent_item->opal_tree_first_child == item &&
        parent_item->opal_tree_last_child == item ) {
        parent_item->opal_tree_first_child = opal_tree_get_first_child(item);
        parent_item->opal_tree_last_child = opal_tree_get_last_child(item);
    } else {
        /* There were multiple children.  If I was the first or last,
           then ensure the parent gets a valid first or last child:
           - If I have children, then my first/last
           - If I have no childen, then my immediate sibling */
        if (parent_item->opal_tree_first_child == item) {
            if (item->opal_tree_num_children > 0) {
                parent_item->opal_tree_first_child =
                    item->opal_tree_first_child;
            } else {
                parent_item->opal_tree_first_child =
                    opal_tree_get_next_sibling(item);
            }
        } else if (parent_item->opal_tree_last_child == item) {
            if (item->opal_tree_num_children > 0) {
                parent_item->opal_tree_last_child =
                    item->opal_tree_last_child;
            } else {
                parent_item->opal_tree_last_child =
                    opal_tree_get_prev_sibling(item);
            }
        }
    }
    parent_item->opal_tree_num_children--;

    return OPAL_SUCCESS;
}

/* delimeter characters that mark items in a serialized stream */
static char *start_lvl = "[";
static char *end_lvl = "]";
static char *end_stream = "E";

/*
 * add item to opal buffer that represents all items of a sub-tree from the
 * item passed in on down.  We exit out of converting tree items once we've
 * done the last child of the tree_item and we are at depth 1.
 */
static int add_tree_item2buf(opal_tree_item_t *tree_item,
                             opal_buffer_t *buf,
                             opal_tree_item_serialize_fn_t fn,
                             int depth
                             )
{
    opal_tree_item_t *first_child;
    int rc;

    do {
        /* add start delim to buffer */
        if (OPAL_SUCCESS !=
            (rc = opal_dss.pack(buf, &start_lvl, 1, OPAL_STRING))){
            return(rc);
        }
        /* add item to opal buffer from class creator */
        fn(tree_item, buf);

        if ((first_child = opal_tree_get_first_child(tree_item))) {
            /* add items for our children */
            if (OPAL_SUCCESS !=
                (rc = add_tree_item2buf(first_child, buf, fn, depth+1))){
                return(rc);
            }
            if (OPAL_SUCCESS !=
                (rc = opal_dss.pack(buf, &end_lvl, 1, OPAL_STRING))){
                return(rc);
            }
        } else {
            /* end item entry */
            if (OPAL_SUCCESS !=
                (rc = opal_dss.pack(buf, &end_lvl, 1, OPAL_STRING))){
                return(rc);
            }
        }

        /* advance to next sibling, if none we'll drop out of
         * loop and return to our parent
         */
        tree_item = opal_tree_get_next_sibling(tree_item);
    } while (tree_item && 1 < depth);

    return(OPAL_SUCCESS);
}

/*
 * serialize tree data
 */
int opal_tree_serialize(opal_tree_item_t *start_item, opal_buffer_t *buffer)
{
    int rc;

    if (OPAL_SUCCESS !=
        (rc = add_tree_item2buf(start_item, buffer,
                                start_item->opal_tree_container->serialize,
                                1))){
        return(rc);
    }
    if (OPAL_SUCCESS !=
        (rc = opal_dss.pack(buffer, &end_stream, 1, OPAL_STRING))){
        return(rc);
    }
    return(OPAL_SUCCESS);
}

static int deserialize_add_tree_item(opal_buffer_t *data,
                                     opal_tree_item_t *parent_item,
                                     opal_tree_item_deserialize_fn_t deserialize,
                                     char **curr_delim,
                                     int depth)
{
    int idx = 1, rc;
    opal_tree_item_t *new_item = NULL;
    int level = 0; /* 0 - one up 1 - curr, 2 - one down */

    if (!*curr_delim) {
        if (OPAL_SUCCESS !=
            (rc = opal_dss.unpack(data, curr_delim, &idx, OPAL_STRING))) {
            return(rc);
        }
    }
    while(*curr_delim[0] != end_stream[0]) {
        if (*curr_delim[0] == start_lvl[0]) {
            level++;
        } else {
            level--;
        }

        switch (level) {
        case 0:
            if (1 < depth) {
                /* done with this level go up one level */
                return(OPAL_SUCCESS);
            }
            break;
        case 1:
            /* add found child at this level */
            deserialize(data, &new_item);
            opal_tree_add_child(parent_item, new_item);
            break;
        case 2:
            /* need to add child one level down */
            deserialize_add_tree_item(data, new_item, deserialize, curr_delim,
                                      depth+1);
            level--;
            break;
        }
        if (OPAL_SUCCESS !=
            (rc = opal_dss.unpack(data, curr_delim, &idx, OPAL_STRING))) {
            return(rc);
        }
    }
    return(OPAL_SUCCESS);
}

/*
 * deserialize tree data
 */
int opal_tree_deserialize(opal_buffer_t *serialized_data,
                          opal_tree_item_t *start_item)
{
    char * null = NULL;
    deserialize_add_tree_item(serialized_data,
                              start_item,
                              start_item->opal_tree_container->deserialize,
                              &null,
                              1);
    return OPAL_SUCCESS;
}

void * opal_tree_get_key(opal_tree_t *tree, opal_tree_item_t *item)
{
    return tree->get_key(item);
}

int opal_tree_dup(opal_tree_t *from, opal_tree_t *to)
{
    int ret;
    opal_buffer_t *buffer = NULL;

    opal_tree_init(to,
                   from->comp,
                   from->serialize,
                   from->deserialize,
                   from->get_key);

    buffer = OBJ_NEW(opal_buffer_t);

    opal_tree_serialize(opal_tree_get_root(from), buffer);
    ret = opal_tree_deserialize(buffer, opal_tree_get_root(to));

    OBJ_RELEASE(buffer);
    return ret;
}

int opal_tree_copy_subtree(opal_tree_t *from_tree, opal_tree_item_t *from_item,
                           opal_tree_t *to_tree,   opal_tree_item_t *to_parent)
{
    int ret;
    opal_buffer_t *buffer = NULL;

    buffer = OBJ_NEW(opal_buffer_t);

    opal_tree_serialize(from_item, buffer);
    ret = opal_tree_deserialize(buffer, to_parent);

    OBJ_RELEASE(buffer);
    return ret;
}

opal_tree_item_t *opal_tree_dup_item(opal_tree_t *base, opal_tree_item_t *from)
{
    opal_buffer_t *buffer = NULL;
    opal_tree_item_t *new_item = NULL;

    buffer = OBJ_NEW(opal_buffer_t);

    opal_tree_serialize(from, buffer);

    new_item = OBJ_NEW(opal_tree_item_t);
    opal_tree_deserialize(buffer, new_item);

    OBJ_RELEASE(buffer);
    return new_item;
}

int opal_tree_num_children(opal_tree_item_t *parent)
{
    opal_tree_item_t *child = NULL;
    int i = 0;

    for(child  = opal_tree_get_first_child(parent);
        child != NULL;
        child  = opal_tree_get_next_sibling(child) ) {
        ++i;
    }

    return i;
}

static int opal_tree_compare_subtrees(opal_tree_t *tree_left, opal_tree_t *tree_right,
                                      opal_tree_item_t *left, opal_tree_item_t *right)
{
    int ret;
    opal_tree_item_t *left_child = NULL, *right_child = NULL;

    /* Basecase */
    if( NULL == left && NULL == right ) {
        return 0; /* Match */
    }

    /* Compare: Depth */
    if( NULL == left && NULL != right ) {
        return -1;
    }
    else if( NULL != left && NULL == right ) {
        return 1;
    }

    /* Compare: Keys */
    if( 0 != tree_left->comp(right, opal_tree_get_key(tree_left, left)) ) {
        return -2;
    }

    /* Compare: Number of children */
    if( opal_tree_num_children(left) != opal_tree_num_children(right) ) {
        return 2;
    }

    /* Recursively compare all children */
    for(left_child  = opal_tree_get_first_child(left),        right_child  = opal_tree_get_first_child(right);
        left_child != NULL &&                                 right_child != NULL;
        left_child  = opal_tree_get_next_sibling(left_child), right_child  = opal_tree_get_next_sibling(right_child) ) {
        /* On first difference, return the result */
        if( 0 != (ret = opal_tree_compare_subtrees(tree_left, tree_right, left_child, right_child)) ) {
            return ret;
        }
    }

    return 0;
}

int opal_tree_compare(opal_tree_t *left, opal_tree_t *right)
{
    return opal_tree_compare_subtrees(left, right, opal_tree_get_root(left), opal_tree_get_root(right));
}

/*
 * search myself, descendants and siblings for item matching key
 */
static opal_tree_item_t *find_in_descendants(opal_tree_item_t* item, void *key)
{
    opal_tree_item_t *result = NULL, *first_child;

    while (!result && item) {
        /* check for item match */
        result = (item->opal_tree_container->comp(item, key) == 0) ?
            item : NULL;
        if (!result && (first_child = opal_tree_get_first_child(item))) {
            /* search descendants for match */
            result = find_in_descendants(first_child, key);
        }
        if (!result) {
            /* didn't find match at our node or descending so check sibling */
            item = opal_tree_get_next_sibling(item);
        }
    }
    return(result);
}

/*
 * return next tree item that matches key
 */
opal_tree_item_t *opal_tree_find_with(opal_tree_item_t *item, void *key)
{
    opal_tree_item_t *curr_item = item, *result = NULL;

    if (!opal_tree_is_empty(item->opal_tree_container)) {
        /* check my descendant for a match */
        result = find_in_descendants(opal_tree_get_first_child(item), key);

        if (!result) {
            /* check my siblings for match */
            if (NULL != (curr_item = opal_tree_get_next_sibling(curr_item))) {
                result = find_in_descendants(curr_item, key);
            }
        }

        /* check my ancestors (uncles) for match */
        curr_item = item;
        while (!result && curr_item && curr_item->opal_tree_num_ancestors > 0){
            curr_item = opal_tree_get_next_sibling(item->opal_tree_parent);
            while (NULL == curr_item &&
                   item->opal_tree_parent->opal_tree_num_ancestors > 0) {
                item = item->opal_tree_parent;
                curr_item = opal_tree_get_next_sibling(item->opal_tree_parent);
            }
            if (curr_item) {
                /* search ancestors descendants for match */
                result = find_in_descendants(curr_item, key);
            }
        }
    }

    return(result);
}