# Top parent hierarchy search

**URL:** <https://forum.knime.com/t/top-parent-hierarchy-search/36417>\
**Category:** KNIME Analytics Platform\
**Created:** [September 29, 2021, 2:23pm UTC](https://forum.knime.com/t/top-parent-hierarchy-search/36417 "2021-09-29T14:23:08Z")\
**Posts on this page:** 8\
**Page:** 2

<div class="post-metadata">

**Author:** ![aworker](https://forum-cdn.knime.com/user_avatar/forum.knime.com/aworker/32/36421_2.png) [@aworker](https://forum.knime.com/u/aworker)\
**Post date:** [September 30, 2021, 1:13pm UTC](https://forum.knime.com/t/top-parent-hierarchy-search/36417/22 "2021-09-30T13:13:34Z")

</div>

Hi @bruno29a

I understand now. Certainly a possible alternative. Thanks for the explanation 😊 !

Best

Ael

---

<div class="post-metadata">

**Author:** ![aworker](https://forum-cdn.knime.com/user_avatar/forum.knime.com/aworker/32/36421_2.png) [@aworker](https://forum.knime.com/u/aworker)\
**Post date:** [September 30, 2021, 1:16pm UTC](https://forum.knime.com/t/top-parent-hierarchy-search/36417/23 "2021-09-30T13:16:22Z")

</div>

Hi @ipazin

I had never used the -Cell Replacer- node so didn’t know about it. Very useful to know and certainly the best solution. Thanks @ipazin😃 👍!

Best

Ael

---

<div class="post-metadata">

**Author:** ![ipazin](https://forum-cdn.knime.com/user_avatar/forum.knime.com/ipazin/32/806_2.png) [@ipazin](https://forum.knime.com/u/ipazin)\
**Post date:** [September 30, 2021, 1:27pm UTC](https://forum.knime.com/t/top-parent-hierarchy-search/36417/24 "2021-09-30T13:27:12Z")

</div>

Tnx @aworker and @bruno29a!  
Cell Replacer is really useful and one of my favorite nodes. And if once gets improvements like wildcards and regex it will supernode 🙂  
Ivan

---

<div class="post-metadata">

**Author:** ![bruno29a](https://forum-cdn.knime.com/user_avatar/forum.knime.com/bruno29a/32/28802_2.png) [@bruno29a](https://forum.knime.com/u/bruno29a)\
**Post date:** [September 30, 2021, 1:42pm UTC](https://forum.knime.com/t/top-parent-hierarchy-search/36417/25 "2021-09-30T13:42:07Z")

</div>

Hi @ipazin , indeed, I can see that. Like @aworker , I’ve never used it before. It’s a very useful node.

---

<div class="post-metadata">

**Author:** ![aworker](https://forum-cdn.knime.com/user_avatar/forum.knime.com/aworker/32/36421_2.png) [@aworker](https://forum.knime.com/u/aworker)\
**Post date:** [September 30, 2021, 1:48pm UTC](https://forum.knime.com/t/top-parent-hierarchy-search/36417/26 "2021-09-30T13:48:20Z")

</div>

> [@ipazin](#):
>
> Also stop criteria is probably a good idea so you don’t have to run large number of iterations to be sure you’ll find parent.

@ipazin Just a comment about the loop stop criteria. Your recursive loop stops at a fix arbitrary number of iterations which is larger than the number of rows. The number of rows is a better upper bound since the loop should not iterate more than the number of rows (i.e. the number of nodes in the graph). This is still an upper bound which could be lowered to the minimum number of iterations. This can be done using as condition that _the LevelUp column had not changed compared to its previous values_, as follows:

 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/4/f/4f45d2557d3cf2b0581cd7e0fe16334577ddfa45.png)

Could the _condition checking_ be implemented with less nodes 🤔 ? Please suggest. I’m curious 😉

Best

Ael

---

<div class="post-metadata">

**Author:** ![ipazin](https://forum-cdn.knime.com/user_avatar/forum.knime.com/ipazin/32/806_2.png) [@ipazin](https://forum.knime.com/u/ipazin)\
**Post date:** [October 1, 2021, 10:45am UTC](https://forum.knime.com/t/top-parent-hierarchy-search/36417/27 "2021-10-01T10:45:53Z")

</div>

Hello @aworker,

the number of rows is indeed better upper bound if not building stop criteria. For a stop criteria I was using similar approach and needed 4 nodes but had different workflow design (no Rule Engines outside loop and one Rule Engine was inside loop to give entire path which led to parent) which allowed me to aggregate on last column to count missing values and stop based on it. Your approach seems better. Alternative that comes to my mind is as always scripting…

Br,  
Ivan

---

<div class="post-metadata">

**Author:** ![aworker](https://forum-cdn.knime.com/user_avatar/forum.knime.com/aworker/32/36421_2.png) [@aworker](https://forum.knime.com/u/aworker)\
**Post date:** [October 1, 2021, 1:53pm UTC](https://forum.knime.com/t/top-parent-hierarchy-search/36417/28 "2021-10-01T13:53:01Z")

</div>

Hi @ipazin

Thanks for the explanation. I appreciate it.

Best

Ael

---

<div class="post-metadata">

**Author:** ![system](https://forum-cdn.knime.com/uploads/default/original/1X/ab3ccf34482a0329361734a18199390177204f15.png) [@system](https://forum.knime.com/u/system)\
**Post date:** [October 8, 2021, 1:53pm UTC](https://forum.knime.com/t/top-parent-hierarchy-search/36417/29 "2021-10-08T13:53:47Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

[Previous page](https://forum.knime.com/t/top-parent-hierarchy-search/36417.md?page=1)
