private boolean needListAlignment(@NotNull ASTNode child) {
    final IElementType childType = child.getElementType();
    if (PyTokenTypes.OPEN_BRACES.contains(childType)) {
      return false;
    }
    if (PyTokenTypes.CLOSE_BRACES.contains(childType)) {
      final ASTNode prevNonSpace = findPrevNonSpaceNode(child);
      if (prevNonSpace != null &&
          prevNonSpace.getElementType() == PyTokenTypes.COMMA &&
          myContext.getMode() == FormattingMode.ADJUST_INDENT) {
        return true;
      }
      return !hasHangingIndent(myNode.getPsi()) && !(myNode.getElementType() == PyElementTypes.DICT_LITERAL_EXPRESSION &&
                                                     myContext.getPySettings().DICT_NEW_LINE_AFTER_LEFT_BRACE);
    }
    if (myNode.getElementType() == PyElementTypes.ARGUMENT_LIST) {
      if (!myContext.getSettings().ALIGN_MULTILINE_PARAMETERS_IN_CALLS || hasHangingIndent(myNode.getPsi())) {
        return false;
      }
      if (childType == PyTokenTypes.COMMA) {
        return false;
      }
      return true;
    }
    if (myNode.getElementType() == PyElementTypes.PARAMETER_LIST) {
      return !hasHangingIndent(myNode.getPsi()) && myContext.getSettings().ALIGN_MULTILINE_PARAMETERS;
    }
    if (myNode.getElementType() == PyElementTypes.SUBSCRIPTION_EXPRESSION) {
      return false;
    }
    if (childType == PyTokenTypes.COMMA) {
      return false;
    }
    if (myNode.getElementType() == PyElementTypes.PARENTHESIZED_EXPRESSION) {
      if (childType == PyElementTypes.STRING_LITERAL_EXPRESSION) {
        return true;
      }
      if (childType != PyElementTypes.TUPLE_EXPRESSION && childType != PyElementTypes.GENERATOR_EXPRESSION) {
        return false;
      }
    }
    if (myNode.getElementType() == PyElementTypes.WITH_STATEMENT) {
      return myNode.findChildByType(PyTokenTypes.LPAR) != null && !hasHangingIndent(myNode.getPsi());
    }
    if (myNode.getElementType() == PyElementTypes.TUPLE_EXPRESSION) {
      final ASTNode prevNode = myNode.getTreeParent();
      if (prevNode.getElementType() != PyElementTypes.PARENTHESIZED_EXPRESSION) {
        return false;
      }
    }
    return myContext.getPySettings().ALIGN_COLLECTIONS_AND_COMPREHENSIONS && !hasHangingIndent(myNode.getPsi());
  }
private boolean needListAlignment(@NotNull ASTNode child)