Parties have rules. The rules specify a process for choosing a candidate. For the Republican and Democrat party the rules are (roughly) "each state chooses delegates to a convention, and the delegates vote on who should be the party's candidate". Any candidate who follows the party rules can be selected by this process. The "hierarchy" is not a formal organisation, so can't act as body. There are, however, mechanisms whereby senior party members can act against a candidate:
An extract of the Democrat party rules for the selection of delgates:
The term “presidential candidate” herein shall
mean any person who, as determined by the
National Chairperson of the Democratic
National Committee, has accrued delegates in
the nominating process and plans to seek the
nomination, has established substantial support
for his or her nomination as the Democratic
candidate for the Office of the President of the
United States, is a bona fide Democrat whose
record of public service, accomplishment, public
writings and/or public statements affirmatively
demonstrates that he or she is faithful to the
interests, welfare and success of the Democratic
Party of the United States, and will participate
in the Convention in good faith.
So there is a process by which one who has accrued delegates can be excluded on the grounds of not being "a bona fide Democrat". I would expect there to be a similar clause in the Republican party.
The rules of any party are subject to legal review. If someone was excluded on the ground that they were not a bona fide Democrat, I would expect lawyers to be become involved quite rapidly. I would also expect that a party that was so divided that it excluded someone who had won a majority of the delegates at the convention to crash and burn at the General election. (But then Trump was elected, so I could be wrong.)