public Selection find(AstNode node) {
    Selection result = null;
    while (result == null) {
      if (node instanceof MethodInvocation) {
        MethodInvocation invocation = (MethodInvocation) node;
        String name = invocation.name();
        AstNode parent = invocation.parent();
        if (name.equals("in") && scopeSet.contains(parent.name())) {
          String testName = getTestNameBottomUp(invocation);
          result =
              testName != null
                  ? new Selection(invocation.className(), testName, new String[] {testName})
                  : null;
          if (testName == null) {
            if (node.parent() != null) {
              node = node.parent();
            } else break;
          }
        } else if (scopeSet.contains(name)) {
          String displayName = getDisplayNameBottomUp(invocation);
          List<String> testNames = getTestNamesTopDown(invocation);
          result =
              new Selection(
                  invocation.className(),
                  displayName,
                  testNames.toArray(new String[testNames.size()]));
        }
      }

      if (result == null) {
        if (node.parent() != null) node = node.parent();
        else break;
      }
    }
    return result;
  }