Remove node comments

@param {Object} t the babel type definition
@param {Object} path the node path
@param {string} type the comment type
function removeComments(t, path, type) {
    let commentPaths = path.get(type);
    if (!commentPaths || !commentPaths.length) {
        return;
    }

    let isLeadingType = type === LEADING_COMMENT_TYPE;
    if (isLeadingType) {
        let parentPath = path.parentPath;
        let isParentProgram = parentPath && t.isProgram(parentPath.node);

        // move leading comments to program
        if (isParentProgram) {
            parentPath.addComments(
                'leading',
                commentPaths.map(item => item.node)
            );
        }
    }

    commentPaths.forEach(item => item.remove());
}