docs: @Nullable
    private static <T> TreePath findEnclosingMethodOrLambdaOrInitializer(TreePath path) {
      while (path != null) {
        if (path.getLeaf() instanceof MethodTree) {
          return path;
        }
        TreePath parent = path.getParentPath();
        if (parent != null) {
          if (parent.getLeaf() instanceof ClassTree) {
            if (path.getLeaf() instanceof BlockTree) {
              // this is a class or instance initializer block
              return path;
            }
            if (path.getLeaf() instanceof VariableTree
                && ((VariableTree) path.getLeaf()).getInitializer() != null) {
              // this is a field with an inline initializer
              return path;
            }
          }
          if (parent.getLeaf() instanceof LambdaExpressionTree) {
            return parent;
          }
        }
        path = parent;
      }
      return null;
    }