Extracting hill contains tree logic