### Question:
ApplicationContextWalker { public BeanDefinition getBeanDefinition(String beanName) { final DoubleRegistry doubleRegistry = applicationContext.getBean(DoubleRegistry.BEAN_NAME, DoubleRegistry.class); return walkContext(ctx -> new BeanDefinitionFinder(ctx, doubleRegistry).tryToFindBeanDefinition(beanName)) .stream() .flatMap(selectOnlyPresentOptionals()) .findFirst() .orElseThrow(() -> new NoSuchBeanDefinitionException("No bean definition for " + beanName)); } ApplicationContextWalker(ApplicationContext applicationContext); BeanDefinition getBeanDefinition(String beanName); boolean hasOnlyOneBeanOfClass(Class<?> beanClass); Collection<String> getBeanDefinitionNames();  }### Answer:
@Test public void should_find_bean_definition_from_any_context_in_hierarchy() { final String childName = "child"; final String middleName = "middle"; final String parentName = "parent"; final ApplicationContext childContext = buildAppContext(Stream.of(bean(childName, new Object()))); final ApplicationContext middleContext = buildAppContext(childContext, Stream.of(bean(middleName, new Object()))); final ApplicationContext parentContext = buildAppContext(middleContext, Stream.of( withEmptyDoubleRegistry(), bean(parentName, new Object()))); final ApplicationContextWalker walker = new ApplicationContextWalker(parentContext); final BeanDefinition childDefinition = walker.getBeanDefinition(childName); final BeanDefinition middleDefinition = walker.getBeanDefinition(middleName); final BeanDefinition parentDefinition = walker.getBeanDefinition(parentName); assertNotNull(childDefinition); assertNotNull(middleDefinition); assertNotNull(parentDefinition); }