lib/utils/yamlAstParser.js/removeExistingArrayItem
const removeExistingArrayItem = (ymlFile, pathInYml, removeValue) =>
  fs.readFileAsync(ymlFile, 'utf8').then(yamlContent => {
    const rawAstObject = yaml.load(yamlContent);
    const astObject = parseAST(rawAstObject);

    if (astObject[pathInYml] && astObject[pathInYml].items) {
      const plainObject = constructPlainObject(rawAstObject);
      const pathInYmlArray = pathInYml.split('.');

      let currentNode = plainObject;
      const pathInObjectTree = [];
      for (let i = 0; i < pathInYmlArray.length - 1; i++) {
        pathInObjectTree.push(currentNode);
        currentNode = currentNode[pathInYmlArray[i]];
      }
      const arrayPropertyName = _.last(pathInYmlArray);
      const arrayProperty = currentNode[arrayPropertyName];
      _.pull(arrayProperty, removeValue);

      if (_.isEmpty(arrayProperty)) {
        _.unset(currentNode, arrayPropertyName);
        pathInObjectTree.push(currentNode);
        for (let i = pathInObjectTree.length - 1; i > 0; i--) {
          if (_.keys(pathInObjectTree[i]).length > 0) {
            break;
          }
          _.unset(pathInObjectTree[i - 1], pathInYmlArray[i - 1]);
        }
      }

      const headObjectPath = _.head(pathInYmlArray);
      let newText = '';

      if (plainObject[headObjectPath]) {
        const newObject = {};
        newObject[headObjectPath] = plainObject[headObjectPath];
        newText = yaml.dump(newObject);
      }
      const beginning = yamlContent.substring(
        0,
        astObject[headObjectPath].parent.key.startPosition
      );
      const end = yamlContent.substring(astObject[pathInYml].endPosition, yamlContent.length);
      return fs.writeFileAsync(ymlFile, `${beginning}${newText}${end}`);
    }
    return BbPromise.resolve();
  });