Get terms with a parent

With the following function you can get the terms which have parent terms, by post id and taxonomy.

function get_terms_with_parent( $post_id, $taxonomy ) {
	if( empty( $post_id ) ) {
		global $post;
		$post_id = $post->;
	}
	$terms = wp_get_post_terms( $post_id, $taxonomy );
	foreach( $terms as $key => $term ) {
		if( $term->parent != 0 ) {
			$new_terms[] = $term;
		}
	}
	return $new_terms;
}