private static boolean containsDependentVariables(List<PsiLocalVariable> variables) {
    if (variables.isEmpty()) return false;
    final Set<PsiLocalVariable> visited = ContainerUtil.newHashSet(variables.get(0));
    for (int i = 1; i < variables.size(); i++) {
      final PsiLocalVariable variable = variables.get(i);
      if (!PsiTreeUtil.processElements(variable.getInitializer(),
                                       element -> !visited.contains(tryResolveLocalVariable(element)))) {
        return true;
      }
      visited.add(variable);
    }
    return false;
  }
private static boolean containsDependentVariables(List<PsiLocalVariable> variables)