@Test
public void canStreamAncestors() throws Exception {

  JPanel panel1 = new JPanel();
  JPanel panel11 = new JPanel();
  JPanel panel12 = new JPanel();
  JPanel panel123 = new JPanel();
  JPanel panel13 = new JPanel();
  panel1.add(panel11);
  panel1.add(panel12);
  panel12.add(panel123);
  panel1.add(panel13);
  TreeWalker treeWalker = new TreeWalker(panel123);
  assertThat(treeWalker.ancestorStream().anyMatch(c -> c == panel12)).isTrue();
  assertThat(treeWalker.ancestorStream().anyMatch(c -> c == panel1)).isTrue();
  assertThat(treeWalker.ancestorStream().anyMatch(c -> c == panel11)).isFalse();
  assertThat(treeWalker.ancestorStream().anyMatch(c -> c == panel13)).isFalse();
}