improve tree analysis

This commit is contained in:
Branislav Stojkovic
2019-03-02 12:48:10 +01:00
parent 40d234d1c4
commit c0c226c580
3 changed files with 7 additions and 10 deletions
@@ -230,25 +230,22 @@ public class Tree {
if (t1 == null) if (t1 == null)
return t2; return t2;
if (t2 == null) if (t2 == null)
return t1; return t1;
if (children == null) if (children == null)
return null; return null;
Tree p1 = null; if (!this.contains(t1) || !this.contains(t2))
Tree p2 = null; return null;
Tree p1 = this;
Tree p2 = this;
for (Tree c : children) { for (Tree c : children) {
if (c.contains(t1)) if (c.contains(t1))
p1 = c; p1 = c;
if (c.contains(t2)) if (c.contains(t2))
p2 = c; p2 = c;
} }
if (p1 == null || p2 == null)
return null;
if (p1 == p2)
return p1;
if (p1 != p2) if (p1 != p2)
return this; return this;
Binary file not shown.
Binary file not shown.